AsyncState

interface AsyncState<S>

Set of operators for UDF state management based on Async.

Types

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

Delegate implementation of AsyncState based on MutableStateFlow.

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
abstract val stateFlow: MutableStateFlow<S>

MutableStateFlow with current state.

Inheritors

Link copied to clipboard