dispose

inline fun Disposable?.dispose(onError: (Exception) -> Unit)

Allows to dispose a resource implementing Disposable interface. Will silently ignore nulls. Exceptions will be caught and passed to onError function. This is basically an alternative to try-catch block usage.

Parameters

onError

will be invoked if an exception (except for JVM internal Errors, which should not be caught anyway) is thrown during asset disposing.


fun <Asset : Disposable> Iterable<Asset?>?.dispose(): Unit?

Allows to dispose a collection of resources implementing Disposable interface. Will silently ignore stored nulls. This method does not affect the Iterable structure in any way: no elements are removed from the collection.


inline fun <Asset : Disposable> Iterable<Asset?>?.dispose(onError: (Exception) -> Unit): Unit?

Allows to dispose a collection of resources implementing Disposable interface. Will silently ignore stored nulls. Exceptions during asset disposing will be caught and passed to onError function. This method does not affect the Iterable structure in any way: no elements are removed from the collection.

Parameters

onError

will be invoked each time an exception (except for JVM internal Errors, which should not be caught anyway) is thrown during asset disposing.


fun <Asset : Disposable> Array<Asset>?.dispose(): Unit?

Allows to dispose a collection of resources implementing Disposable interface. Will silently ignore stored nulls. This method does not affect the Array structure in any way: no elements are removed from the array.


inline fun <Asset : Disposable> Array<Asset>?.dispose(onError: (Exception) -> Unit): Unit?

Allows to dispose a collection of resources implementing Disposable interface. Will silently ignore stored nulls. Exceptions during asset disposing will be caught and passed to onError function. This method does not affect the Array structure in any way: no elements are removed from the array.

Parameters

onError

will be invoked each time an exception (except for JVM internal Errors, which should not be caught anyway) is thrown during asset disposing.