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

flowScoped

@ExperimentalCoroutinesApi @MainThread fun <S : State, A : Action> Store<S, A>.flowScoped(owner: LifecycleOwner? = null, block: suspend (Flow<S>) -> Unit): CoroutineScope (source)

Launches a coroutine in a new MainScope and creates a Flow for observing State changes in the Store in that scope. Invokes block inside that scope and passes the Flow to it.

Parameters

owner - An optional 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 emitted.

Return The CoroutineScope is getting executed in.