StateReceiver

An entity that handles MVIState updates. This entity modifies the state of the StateProvider. This is most often implemented by a Store and exposed through PipelineContext.

Implements ImmediateStateReceiver

Inheritors

Properties

Link copied to clipboard

Obtain the current state in an unsafe manner.

Link copied to clipboard
abstract override val states: StateFlow<S>

A flow of states to be rendered by the subscriber.

Functions

Link copied to clipboard
abstract fun compareAndSet(old: S, new: S): Boolean

Directly compare and set the current state.

Link copied to clipboard
abstract suspend fun updateState(transform: suspend S.() -> S)

Obtain the current StateProvider.state and update it with the result of transform.

Link copied to clipboard
inline suspend fun <T : S, S : MVIState> StateReceiver<S>.updateState(crossinline transform: suspend T.() -> S)

A typed overload of StateReceiver.updateState.

Link copied to clipboard
@JvmName(name = "updateStateImmediateTyped")
inline fun <T : S, S : MVIState> ImmediateStateReceiver<S>.updateStateImmediate(transform: T.() -> S)

A typed overload of updateStateImmediate.

inline fun <S : MVIState> ImmediateStateReceiver<S>.updateStateImmediate(transform: S.() -> S)

A function that obtains current state and updates it atomically (in the thread context), and non-atomically in the coroutine context, which means it can cause races when you want to update states in parallel.

Link copied to clipboard
abstract suspend fun withState(block: suspend S.() -> Unit)

Obtain the current state and operate on it without changing the state.

Link copied to clipboard
inline suspend fun <T : S, S : MVIState> StateReceiver<S>.withState(crossinline block: suspend T.() -> Unit)

A typed overload of StateReceiver.withState.