-
public interface StreamObservable<T extends Object>Interface for observables that can be subscribed to.
-
-
Method Summary
Modifier and Type Method Description abstract Result<StreamSubscription>subscribe(T listener, StreamSubscriptionManager.Options options)Adds listener to the active set and returns a handle that can later be used to unregister it. -
-
Method Detail
-
subscribe
abstract Result<StreamSubscription> subscribe(T listener, StreamSubscriptionManager.Options options)
Adds listener to the active set and returns a handle that can later be used to unregister it.
The returned StreamSubscription is idempotent:
Calling
cancel()multiple times is safe.After
cancel()completes, the listener is guaranteed to be absent from subsequent forEach iterations.
Retention:
When options.retention is Options.Retention.AUTO_REMOVE (default), you can omit calling
cancel(). Once your code drops all references to the listener, it is removed automatically and will no longer receive events.When options.retention is Options.Retention.KEEP_UNTIL_CANCELLED, you must call
cancel()(or invoke clear) to stop events.
- Parameters:
listener- The listener to register.options- Retention options; defaults to automatic removal when the listener is no longer referenced.
-
-
-
-