StateHandlerHolder

class StateHandlerHolder<I : State>(inputKlass: KClass<I>, strict: Boolean, delegateTo: StatesHandler<I>) : StatesHandler<State>

Default realization of StatesHandler. It will incapsulate checking of State type in checkHandleable and class casting in handleState

Constructors

StateHandlerHolder
Link copied to clipboard
common
fun <I : State> StateHandlerHolder(inputKlass: KClass<I>, strict: Boolean = false, delegateTo: StatesHandler<I>)

Functions

checkHandleable
Link copied to clipboard
common
fun checkHandleable(state: State): Boolean

Checks that state can be handled by delegateTo. Under the hood it will check exact equality of state and use KClass.isInstance of inputKlass if strict == false

handleState
Link copied to clipboard
common
open suspend override fun StatesMachine.handleState(state: State): State?

Calls delegateTo method StatesHandler.handleState with state casted to I. Use checkHandleable to be sure that this StateHandlerHolder will be able to handle state