autodispose-lifecycle / com.uber.autodispose.lifecycle / LifecycleScopes / resolveScopeFromLifecycle

resolveScopeFromLifecycle

static fun <E : Any> resolveScopeFromLifecycle(provider: LifecycleScopeProvider<E>): CompletableSource

Overload for resolving lifecycle providers that defaults to checking start and end boundaries of lifecycles. That is, they will ensure that the lifecycle has both started and not ended.

Note: This resolves the scope immediately, so consider deferring execution as needed, such as using defer.

Parameters

provider - the LifecycleScopeProvider to resolve.

- the lifecycle event type

Exceptions

OutsideScopeException - if the LifecycleScopeProvider#correspondingEvents() throws an OutsideScopeException during resolution.

Return
a resolved CompletableSource representation of a given provider

static fun <E : Any> resolveScopeFromLifecycle(provider: LifecycleScopeProvider<E>, checkEndBoundary: Boolean): CompletableSource

Overload for resolving lifecycle providers allows configuration of checking "end" boundaries of lifecycles. That is, they will ensure that the lifecycle has both started and not ended, and otherwise will throw one of LifecycleNotStartedException (if returns null) or if the lifecycle is ended. To configure the runtime behavior of these exceptions, see AutoDisposePlugins.

Note: This resolves the scope immediately, so consider deferring execution as needed, such as using defer.

Parameters

provider - the LifecycleScopeProvider to resolve.

checkEndBoundary - whether or not to check that the lifecycle has ended

- the lifecycle event type

Exceptions

OutsideScopeException - if the LifecycleScopeProvider#correspondingEvents() throws an OutsideScopeException during resolution.

Return
a resolved CompletableSource representation of a given provider

static fun <E : Any> resolveScopeFromLifecycle(lifecycle: Observable<E>, endEvent: E): CompletableSource

Parameters

lifecycle - the stream of lifecycle events

endEvent - the target end event

- the lifecycle event type

Return
a resolved Completable representation of a given lifecycle, targeting the given event

static fun <E : Any> resolveScopeFromLifecycle(lifecycle: Observable<E>, endEvent: E, @Nullable comparator: Comparator<E>?): CompletableSource

Parameters

lifecycle - the stream of lifecycle events

endEvent - the target end event

comparator - an optional comparator for checking event equality.

- the lifecycle event type

Return
a resolved Completable representation of a given lifecycle, targeting the given event