CustomizableHandlerHolder

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

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

Constructors

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

Functions

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

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

Extensions

Link copied to clipboard
inline fun <I : O, O : State> StatesHandler<I, O>.holder(strict: Boolean = true): CustomizableHandlerHolder<O, O>
inline fun <I : O, O : State> StatesHandler<I, O>.holder(noinline filter: suspend (state: State) -> Boolean): CustomizableHandlerHolder<O, O>