Package io.kvision.state

Classes supporting the observer pattern, including the implementation of the observable list.

Functions

bind
Link copied to clipboard
fun <S, W : Widget> W.bind(stateFlow: StateFlow<S>, removeChildren: Boolean = true, runImmediately: Boolean = true, factory: W.(S) -> Unit): W

An extension function which binds the widget to the given state flow.

bindEach
Link copied to clipboard
fun <S, W : SimplePanel> W.bindEach(stateFlow: StateFlow<List<S>>, equalizer: (S, S) -> Boolean? = null, factory: SimplePanel.(S) -> Unit): W

An extension function which binds the container to the given state flow of a list of items.

bindSync
Link copied to clipboard
fun <S, W : Component> W.bindSync(stateFlow: StateFlow<S>, removeChildren: Boolean = true, runImmediately: Boolean = true, factory: W.(S) -> Unit): W

An extension function which binds the widget to the given state flow synchronously. It's less efficient than bind, but fully compatible with KVision 4 state bindings.

bindTo
Link copied to clipboard
fun <S, T : GenericFormComponent<S>> T.bindTo(mutableStateFlow: MutableStateFlow<S>): T
fun <T : GenericFormComponent<Number?>> T.bindTo(mutableStateFlow: MutableStateFlow<Double?>): T
fun <T : GenericFormComponent<Number?>> T.bindTo(mutableStateFlow: MutableStateFlow<Double>): T
fun <T : GenericFormComponent<Number?>> T.bindTo(mutableStateFlow: MutableStateFlow<Int?>): T
fun <T : GenericFormComponent<Number?>> T.bindTo(mutableStateFlow: MutableStateFlow<Int>): T
fun <T : GenericFormComponent<String?>> T.bindTo(mutableStateFlow: MutableStateFlow<String>): T
fun <T : GenericFormComponent<Date?>> T.bindTo(mutableStateFlow: MutableStateFlow<Date>): T

Bidirectional data binding to the MutableStateFlow instance.

insert
Link copied to clipboard
fun <S, W : Container> W.insert(stateFlow: StateFlow<S>, removeChildren: Boolean = true, runImmediately: Boolean = true, factory: Container.(S) -> Unit)

An extension function which inserts child component and binds it to the given state flow.

insertNotNull
Link copied to clipboard
fun <S, W : Container> W.insertNotNull(stateFlow: StateFlow<S?>, removeChildren: Boolean = true, runImmediately: Boolean = true, factory: Container.(S) -> Unit)

An extension function which inserts child component and binds it to the given state flow when the state value is not null.

insertWhen
Link copied to clipboard
fun <S, W : Container> W.insertWhen(stateFlow: StateFlow<S>, condition: (S) -> Boolean, removeChildren: Boolean = true, runImmediately: Boolean = true, factory: Container.(S) -> Unit)

An extension function which inserts child component and binds it to the given state flow when the given condition is true.

stateFlow
Link copied to clipboard
fun <T, S> ObservableState<S>.stateFlow(sub: (S) -> T): StateFlow<T>

Extension function returning a sub StateFlow for an ObservableState.

subFlow
Link copied to clipboard
fun <T, S> StateFlow<S>.subFlow(sub: (S) -> T): StateFlow<T>

Extension function returning a sub state flow.

Properties

mutableState
Link copied to clipboard
val <S> MutableStateFlow<S>.mutableState: MutableState<S>

Extension property returning a MutableState for a MutableStateFlow.

mutableStateFlow
Link copied to clipboard
val <S> MutableState<S>.mutableStateFlow: MutableStateFlow<S>

Extension property returning a MutableStateFlow for a MutableState.

observableState
Link copied to clipboard
val <S> StateFlow<S>.observableState: ObservableState<S>

Extension property returning an ObservableState for a StateFlow.

observableState
Link copied to clipboard
val <S> Flow<S>.observableState: ObservableState<S?>

Extension property returning an ObservableState for a Flow.

stateFlow
Link copied to clipboard
val <S> ObservableState<S>.stateFlow: StateFlow<S>

Extension property returning a StateFlow for an ObservableState.