Loop

abstract class Loop<out TState : Any, TModel : Any, in TArgs, TDependency, in TAction : Action<TModel, TDependency>>(model: TModel, renderer: Renderer<TState, TModel>, args: TArgs? = null, argsApplyer: ArgsApplyer<TModel, TArgs>? = null, onStart: ActionEmitter<TModel, TDependency>.() -> Unit = {}, dependency: TDependency? = null, effectContext: CoroutineContext = Dispatchers.IO) : ActionEmitter<TModel, TDependency>

Base class that handles unidirectional data flow.

Parameters

model

the initial model

renderer

transform model into state

args

input arguments

argsApplyer

method to apply new args to the model

onStart

block to run before beginning to collect the loop actions

dependency

dependency container

effectContext

dispatcher for launching effects

Inheritors

Constructors

Link copied to clipboard
constructor(model: TModel, renderer: Renderer<TState, TModel>, args: TArgs? = null, argsApplyer: ArgsApplyer<TModel, TArgs>? = null, onStart: ActionEmitter<TModel, TDependency>.() -> Unit = {}, dependency: TDependency? = null, effectContext: CoroutineContext = Dispatchers.IO)

Properties

Link copied to clipboard

The first state of this com.ekezet.hurok.Loop in a blocking fashion. Useful for testing.

Link copied to clipboard
val state: Flow<TState>

The current state produced by this loop

Functions

Link copied to clipboard

Apply new arguments to this loop.

Link copied to clipboard

Attach this loop as a child to another loop.

Link copied to clipboard
override fun emit(action: Action<TModel, TDependency>)

Emit an action to change the state or trigger an effect.

Link copied to clipboard
fun startIn(scope: CoroutineScope): Job

Start the loop in the given scope.