uniflow-core / io.uniflow.core.flow / StatePublisher

StatePublisher

interface StatePublisher

Component for State publishing

publishState - implementation used by setState getState - get current state

Functions

getState

abstract fun getState(): UIState

publishState

abstract suspend fun publishState(state: UIState, pushStateUpdate: Boolean = true): Unit

setState

open suspend fun setState(state: UIState): Unit
open suspend fun setState(state: () -> UIState): Unit

Extension Functions

getStateOrNull

fun <T : UIState> StatePublisher.getStateOrNull(): T?

Get state for type T or return null

letOnState

fun <T : UIState, R : Any> StatePublisher.letOnState(code: (T) -> R): R?

Let execute block on given state T if not null, return a Result R

onState

fun <T : UIState> StatePublisher.onState(code: (T) -> Unit): Unit

Let execute block on given state T if not null

Inheritors

DataPublisher

interface DataPublisher : StatePublisher, EventPublisher

Component that handle State & Event