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

Package mozilla.components.lib.state.ext

Extensions for External Classes

Name Summary
androidx.fragment.app.Fragment  

Functions

Name Summary
channel fun <S : State, A : Action> Store<S, A>.channel(owner: LifecycleOwner = ProcessLifecycleOwner.get()): ReceiveChannel<S>
Creates a conflated Channel for observing State changes in the Store.
consumeFrom fun <S : State, A : Action> <ERROR CLASS>.consumeFrom(store: Store<S, A>, owner: LifecycleOwner, block: (S) -> Unit): Unit
Helper extension method for consuming State from a Store sequentially in order scoped to the lifetime of the View. The block function will get invoked for every State update.
flow fun <S : State, A : Action> Store<S, A>.flow(owner: LifecycleOwner? = null): Flow<S>
Creates a Flow for observing State changes in the Store.
flowScoped fun <S : State, A : Action> Store<S, A>.flowScoped(owner: LifecycleOwner? = null, block: suspend (Flow<S>) -> Unit): CoroutineScope
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.
observe fun <S : State, A : Action> Store<S, A>.observe(owner: LifecycleOwner, observer: Observer<S>): Unit
Registers an Observer function that will be invoked whenever the state changes. The Store.Subscription will be bound to the passed in LifecycleOwner. Once the Lifecycle state changes to DESTROYED the Observer will be unregistered automatically.fun <S : State, A : Action> Store<S, A>.observe(view: <ERROR CLASS>, observer: Observer<S>): Unit
Registers an Observer function that will be invoked whenever the state changes. The Store.Subscription will be bound to the passed in View. Once the View gets detached the Observer will be unregistered automatically.
observeForever fun <S : State, A : Action> Store<S, A>.observeForever(observer: Observer<S>): Unit
Registers an Observer function that will observe the store indefinitely.