ConditionBuilder

@ExperimentalCoroutinesApi
class ConditionBuilder<InputState : S, S : Any, A : Any> : BaseBuilder<InputState, S, A>

Functions

Link copied to clipboard
fun <T> collectWhileInState(flowBuilder: (InputState) -> Flow<T>, executionPolicy: ExecutionPolicy = ExecutionPolicy.Ordered, handler: suspend ChangeableState<InputState>.(item: T) -> ChangedState<S>)

Triggers every time the state machine enters this state. The passed Flow created by flowBuilder will be collected and any emission will be passed to handler.

fun <T> collectWhileInState(flow: Flow<T>, executionPolicy: ExecutionPolicy = ExecutionPolicy.Ordered, handler: suspend ChangeableState<InputState>.(item: T) -> ChangedState<S>)

Triggers every time the state machine enters this state. The passed flow will be collected and any emission will be passed to handler.

Link copied to clipboard
fun <T> collectWhileInStateEffect(flowBuilder: (InputState) -> Flow<T>, executionPolicy: ExecutionPolicy = ExecutionPolicy.Ordered, handler: suspend State<InputState>.(item: T) -> Unit)
fun <T> collectWhileInStateEffect(flow: Flow<T>, executionPolicy: ExecutionPolicy = ExecutionPolicy.Ordered, handler: suspend State<InputState>.(item: T) -> Unit)

An effect is a way to do some work without changing the state. A typical use case is to trigger navigation as some sort of side effect or triggering analytics or do logging.

Link copied to clipboard
inline fun <SubAction : A> on(executionPolicy: ExecutionPolicy = ExecutionPolicy.CancelPrevious, noinline handler: suspend ChangeableState<InputState>.(action: SubAction) -> ChangedState<S>)

Triggers every time an action of type SubAction is dispatched while the state machine is in this state.

Link copied to clipboard
inline fun <SubAction : A> onActionEffect(executionPolicy: ExecutionPolicy = ExecutionPolicy.CancelPrevious, noinline handler: suspend State<InputState>.(action: SubAction) -> Unit)

An effect is a way to do some work without changing the state. A typical use case would be trigger navigation as some sort of side effect or triggering analytics. This is the "effect counterpart" to handling actions that you would do with on.

Link copied to clipboard
inline fun <SubAction : A, SubStateMachineState : Any> onActionStartStateMachine(noinline stateMachineFactory: (SubAction, InputState) -> StateMachine<SubStateMachineState, A>, noinline stateMapper: ChangeableState<InputState>.(SubStateMachineState) -> ChangedState<S>)
inline fun <SubAction : A, SubStateMachineState : Any, SubStateMachineAction : Any> onActionStartStateMachine(noinline stateMachineFactory: (SubAction, InputState) -> StateMachine<SubStateMachineState, SubStateMachineAction>, noinline actionMapper: (A) -> SubStateMachineAction?, noinline stateMapper: ChangeableState<InputState>.(SubStateMachineState) -> ChangedState<S>)
Link copied to clipboard
fun onEnter(handler: suspend ChangeableState<InputState>.() -> ChangedState<S>)

Triggers every time the state machine enters this state. It only triggers again if the surrounding in<State> condition is met and will only re-trigger if in<State> condition returned false and then true again.

Link copied to clipboard
fun onEnterEffect(handler: suspend State<InputState>.() -> Unit)

An effect is a way to do some work without changing the state. A typical use case is to trigger navigation as some sort of side effect or triggering analytics or do logging.

Link copied to clipboard
fun <SubStateMachineState : Any> onEnterStartStateMachine(stateMachine: StateMachine<SubStateMachineState, A>, stateMapper: ChangeableState<InputState>.(SubStateMachineState) -> ChangedState<S> = { OverrideState(it as S) })
fun <SubStateMachineState : Any> onEnterStartStateMachine(stateMachineFactory: (InputState) -> StateMachine<SubStateMachineState, A>, stateMapper: ChangeableState<InputState>.(SubStateMachineState) -> ChangedState<S> = { OverrideState(it as S) })
fun <SubStateMachineState : Any, SubStateMachineAction : Any> onEnterStartStateMachine(stateMachineFactory: (InputState) -> StateMachine<SubStateMachineState, SubStateMachineAction>, actionMapper: (A) -> SubStateMachineAction?, stateMapper: ChangeableState<InputState>.(SubStateMachineState) -> ChangedState<S> = { OverrideState(it as S) })
Link copied to clipboard
fun untilIdentityChanges(identity: (InputState) -> Any?, block: IdentityBuilder<InputState, S, A>.() -> Unit)

Anything inside this block will only run while the identity of the current state remains the same. The identity is determined by the given function and uses equals for the comparison.