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 : Component> 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.

fun <S, T, W : Component> W.bind(stateFlow: StateFlow<S>, sub: (S) -> T, removeChildren: Boolean = true, runImmediately: Boolean = true, factory: W.(T) -> Unit): W

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

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.

fun <S, T, W : SimplePanel> W.bindEach(stateFlow: StateFlow<S>, sub: (S) -> List<T>, equalizer: (T, T) -> Boolean? = null, factory: SimplePanel.(T) -> Unit): W

An extension function which binds the container to the given state flow using the sub flow extractor to get 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.

fun <S, T, W : Component> W.bindSync(stateFlow: StateFlow<S>, sub: (S) -> T, removeChildren: Boolean = true, runImmediately: Boolean = true, factory: W.(T) -> Unit): W

An extension function which binds the widget to the given state flow synchronously using the sub flow extractor. 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 : SimplePanel> W.insert(stateFlow: StateFlow<S>, removeChildren: Boolean = true, runImmediately: Boolean = true, factory: SimplePanel.(S) -> Unit): SimplePanel

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

fun <S, T, W : SimplePanel> W.insert(stateFlow: StateFlow<S>, sub: (S) -> T, removeChildren: Boolean = true, runImmediately: Boolean = true, factory: SimplePanel.(T) -> Unit): SimplePanel

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

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

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

fun <S, T, W : SimplePanel> W.insertNotNull(stateFlow: StateFlow<S>, sub: (S) -> T?, removeChildren: Boolean = true, runImmediately: Boolean = true, factory: SimplePanel.(T) -> Unit): SimplePanel

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

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

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

fun <S, T, W : SimplePanel> W.insertWhen(stateFlow: StateFlow<S>, sub: (S) -> T, condition: (T) -> Boolean, removeChildren: Boolean = true, runImmediately: Boolean = true, factory: SimplePanel.(T) -> Unit): SimplePanel

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

subFlow
Link copied to clipboard
fun <T, S> StateFlow<S>.subFlow(contextScope: CoroutineScope = KVScope, 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.