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


@ExperimentalCoroutinesApi fun <S : State, A : Action> <ERROR CLASS>.consumeFrom(store: Store<S, A>, owner: LifecycleOwner, block: (S) -> Unit): Unit (source)

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.

This helper will automatically stop observing the Store once the View gets detached. The provided LifecycleOwner is used to determine when observing should be stopped or resumed.

Inside a Fragment prefer to use Fragment.consumeFrom.