uniflow-core / io.uniflow.core.flow / DataFlow

DataFlow

interface DataFlow

Unidirectional Data Flow

A component that is able to declare new action, and dispatch to an internal reducer processor

ActionDispatcher - Have at least one DataPublisher, to publish State/Event data

onError - default error handling behavior that can be overloaded

Author
Arnaud Giuliani

Properties

actionDispatcher

abstract val actionDispatcher: ActionDispatcher

coroutineScope

abstract val coroutineScope: CoroutineScope

tag

abstract val tag: String

Functions

action

open fun action(onAction: ActionFunction): Unit
open fun action(onAction: ActionFunction, onError: ActionErrorFunction): Unit

defaultPublisher

abstract fun defaultPublisher(): DataPublisher

onError

open suspend fun onError(error: Exception, currentState: UIState): Unit

Extension Functions

actionOn

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

onFlow

fun <T> DataFlow.onFlow(flow: () -> Flow<T>, doAction: suspend UIState.(T) -> Unit): Job
fun <T> DataFlow.onFlow(flow: () -> Flow<T>, doAction: suspend UIState.(T) -> Unit, onError: ActionErrorFunction): Job