android-components / mozilla.components.browser.state.store / BrowserStore

BrowserStore

class BrowserStore : Store<BrowserState, BrowserAction> (source)

The BrowserStore holds the BrowserState (state tree).

The only way to change the BrowserState inside BrowserStore is to dispatch an Action on it.

Constructors

Name Summary
<init> BrowserStore(initialState: BrowserState = BrowserState())
The BrowserStore holds the BrowserState (state tree).

Inherited Properties

Name Summary
state val state: S
The current State.

Inherited Functions

Name Summary
dispatch fun dispatch(action: A): Job
Dispatch an Action to the store in order to trigger a State change.
observeManually fun observeManually(observer: Observer<S>): Subscription<S, A>
Registers an Observer function that will be invoked whenever the State changes.

Extension 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.
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.