CustomizableHandlerHolder

class CustomizableHandlerHolder<I : O, O : State>(delegateTo: StatesHandler<I, O>, filter: suspend (O) -> Boolean) : CheckableHandlerHolder<I, O>

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

Constructors

CustomizableHandlerHolder
Link copied to clipboard
fun <I : O, O : State> CustomizableHandlerHolder(delegateTo: StatesHandler<I, O>, filter: suspend (O) -> Boolean)

Functions

checkHandleable
Link copied to clipboard
open suspend override fun checkHandleable(state: O): 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
open suspend override fun StatesMachine<in O>.handleState(state: I): O?

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