android-components / mozilla.components.lib.state.ext / channel

channel

@ExperimentalCoroutinesApi @MainThread fun <S : State, A : Action> Store<S, A>.channel(owner: LifecycleOwner = ProcessLifecycleOwner.get()): ReceiveChannel<S> (source)

Creates a conflated Channel for observing State changes in the Store.

The advantage of a Channel is that State changes can be processed sequentially in order from a single coroutine (e.g. on the main thread).

Parameters

owner - A LifecycleOwner that will be used to determine when to pause and resume the store subscription. When the Lifecycle is in STOPPED state then no State will be received. Once the Lifecycle switches back to at least STARTED state then the latest State and further updates will be received.