android-components / mozilla.components.lib.state / Store / observeManually


@CheckResult("observe") @Synchronized fun observeManually(observer: Observer<S>): Subscription<S, A> (source)

Registers an Observer function that will be invoked whenever the State changes.

It’s the responsibility of the caller to keep track of the returned Subscription and call Subscription.unsubscribe to stop observing and avoid potentially leaking memory by keeping an unused Observer registered. It’s is recommend to use one of the observe extension methods that unsubscribe automatically.

The created Subscription is in paused state until explicitly resumed by calling Subscription.resume. While paused the Subscription will not receive any state updates. Once resumed the observer will get invoked immediately with the latest state.

Return A Subscription object that can be used to unsubscribe from further state changes.