Package-level declarations


public interface LifecycleScopeProviderextends ScopeProvider {
  Observable

A common use case for this is objects that have implicit lifecycles, such as Android's Activity, Fragment, and View classes. Internally at subscription-time, AutoDispose will resolve a io.reactivex.CompletableSource representation of the target end event in the lifecycle, and exposes an API to dictate what corresponding events are for the current lifecycle state (e.g. ATTACH ->DETACH). This also allows you to enforce lifecycle boundary requirements, and by default will error if the lifecycle has either not started yet or has already ended.

autodispose2.lifecycle.LifecycleScopeProvider is a special case targeted at binding to things with lifecycles. Its API is as follows: - lifecycle - returns an of lifecycle events. This should be backed by a or something similar (BehaviorRelay, etc). - correspondingEvents - a mapping of events to corresponding ones, i.e. Attach -> Detach. - peekLifecycle - returns the current lifecycle state of the object.

In requestScope, the implementation expects to these pieces to construct a io.reactivex.CompletableSource representation of the proper end scope, while also doing precondition checks for lifecycle boundaries. If a lifecycle has not started, it will send you to onError with a . If the lifecycle as ended, it is recommended to throw a autodispose2.lifecycle.LifecycleEndedException in your correspondingEvents() mapping, but it is up to the user.

To simplify implementations, there's an included utility class with factories for generating representations from instances.

Types

Link copied to clipboard
A corresponding events function that acts as a normal Function but ensures a single event type in the generic and tightens the possible exception thrown to OutsideScopeException.
Link copied to clipboard
Signifies an error occurred due to execution starting after the lifecycle has ended.
Link copied to clipboard
Signifies an error occurred due to execution starting before the lifecycle has started.
Link copied to clipboard
@DoNotMock(value = "Use TestLifecycleScopeProvider instead")
interface LifecycleScopeProvider<@NonNull E> : ScopeProvider
A convenience interface that, when implemented, helps provide information to create implementations that resolve the next corresponding lifecycle event and construct a Completable representation of it from the lifecycle stream.
Link copied to clipboard
Utilities for dealing with LifecycleScopeProviders.
Link copied to clipboard
Test utility to create LifecycleScopeProvider instances for tests.