DisposableScope

Represents a scope of Disposables. All scoped Disposables are disposed when the DisposableScope is disposed.

The following factory functions are available:

Properties

Link copied to clipboard
abstract val isDisposed: Boolean

Checks whether this resource is disposed or not

Functions

Link copied to clipboard
abstract fun dispose()

Disposes this resource

Link copied to clipboard
inline fun DisposableScope.doOnDispose(crossinline block: () -> Unit)

Adds the provided block callback to the scope. The callback will be called when the scope is disposed.

Link copied to clipboard
abstract fun <T : Disposable> T.scope(): T

Adds this Disposable to the scope

abstract fun <T> T.scope(onDispose: (T) -> Unit): T
Link copied to clipboard
abstract fun Completable.subscribeScoped(onSubscribe: (Disposable) -> Unit? = null, onError: (Throwable) -> Unit? = null, onComplete: () -> Unit? = null): Disposable

Same as Completable.subscribe but also adds the Disposable to the scope

abstract fun <T> Single<T>.subscribeScoped(onSubscribe: (Disposable) -> Unit? = null, onError: (Throwable) -> Unit? = null, onSuccess: (T) -> Unit? = null): Disposable

Same as Single.subscribe but also adds the Disposable to the scope

abstract fun <T> Maybe<T>.subscribeScoped(onSubscribe: (Disposable) -> Unit? = null, onError: (Throwable) -> Unit? = null, onComplete: () -> Unit? = null, onSuccess: (T) -> Unit? = null): Disposable

Same as Maybe.subscribe but also adds the Disposable to the scope

abstract fun <T> Observable<T>.subscribeScoped(onSubscribe: (Disposable) -> Unit? = null, onError: (Throwable) -> Unit? = null, onComplete: () -> Unit? = null, onNext: (T) -> Unit? = null): Disposable

Same as Observable.subscribe but also adds the Disposable to the scope