uniflow-core / io.uniflow.core.flow

Package io.uniflow.core.flow

Types

Action

class Action

Wrap a function that will set a new state or event, regarding current state We can target a specific State KClass to ensure we want to execute on it

ActionDispatcher

class ActionDispatcher

Handle dispatch logic to ActionReducer, help wrap Action dispatchAction - Help dispatch given action to ActionReducer, on given coroutineScope context. actionOn - Handle default error behavior by routing back to ::onError function

ActionReducer

open class ActionReducer

Action processor component, backed by a coroutine Actor to execute a queue of Actions

DataFlow

interface DataFlow

Unidirectional Data Flow

DataPublisher

interface DataPublisher : StatePublisher, EventPublisher

Component that handle State & Event

EventPublisher

interface EventPublisher

Component for Event publishing

StatePublisher

interface StatePublisher

Component for State publishing

Type Aliases

ActionErrorFunction

typealias ActionErrorFunction = suspend (Exception, UIState) -> Unit

ActionErrorFunction_T

typealias ActionErrorFunction_T<T> = suspend (Exception, T) -> Unit

ActionFunction

typealias ActionFunction = suspend (UIState) -> Unit

ActionFunction_T

typealias ActionFunction_T<T> = suspend (T) -> Unit

Functions

actionOn

fun <T : UIState> DataFlow.actionOn(onAction: ActionFunction_T<T>): Action
fun <T : UIState> DataFlow.actionOn(onAction: ActionFunction_T<T>, onError: ActionErrorFunction_T<T>): Action

getStateOrNull

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

onState

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