Delegate

class Delegate<S>(initialState: S) : AsyncState<S>

Delegate implementation of AsyncState based on MutableStateFlow.

Constructors

Link copied to clipboard
fun <S> Delegate(initialState: S)

Functions

Link copied to clipboard
open fun <V> ScopedDeferred<V>.catchAsState(initialState: Async<V>? = Loading(), reducer: S.(Async<V>) -> S): Job

Await value and update state with reducer.

Link copied to clipboard
open fun <V> Flow<V>.collectAsState(scope: CoroutineScope, initialState: Async<V>? = Loading(), reducer: S.(Async<V>) -> S): Job

Collect flow of values and update state with reducer.

Link copied to clipboard
open fun <V> Flow<Async<V>>.collectAsyncAsState(scope: CoroutineScope, initialState: Async<V>? = Loading(), reducer: S.(Async<V>) -> S): Job

Collect flow of values wrapped in Async and update state with reducer.

Link copied to clipboard
open fun <V> Flow<Result<V>>.collectReduceAsState(scope: CoroutineScope, initialState: Async<V>? = Loading(), reducer: S.(Async<V>) -> S): Job

Collect flow of values wrapped in Result and update state with reducer.

Link copied to clipboard
open fun <V> ScopedDeferred<Result<V>>.reduceAsState(initialState: Async<V>? = Loading(), reducer: S.(Async<V>) -> S): Job

Await result and update state with reducer.

Link copied to clipboard
open fun <P> CoroutineScope.selectSubscribe(property: KProperty1<S, P>, block: (P) -> Unit): Job

Subscribe for property changes in state.

Link copied to clipboard
open fun setState(reducer: S.() -> S)

Update current state with reducer.

Link copied to clipboard
open fun withState(block: (state: S) -> Unit)

Provide current state in block

Properties

Link copied to clipboard
open override val stateFlow: MutableStateFlow<S>

MutableStateFlow with current state.