ComposeStateCallbacks

An implementation of StateCallback that composes two other state callbacks. Consider that we were only dealing with regular functions, this would give:

fun a(state: R): U
fun b(state: U): V

Then, this class would be equivalent to the following function:

fun composed(state: R): U = b(a(state))

Parameters

T

Context type, see NodeParameterKey for details

R

Input type of the a state callback

U

Output type of the a state callback and input type of the b state callback

V

Output type of the b state callback

Constructors

Link copied to clipboard
constructor(a: StateCallback<T, R, U>, b: StateCallback<T, U, V>)

Functions

Link copied to clipboard
fun <T, R> StateCallback<T, R, *>?.createStoreMap(value: R): Map<NodeParameterKey<T, *>, Any?>

Create a store map and evaluate this state callback. The map is returned.

Link copied to clipboard
open override fun reduceState(storage: MutableMap<NodeParameterKey<T, *>, Any?>, state: R): V

Reduce the provided state, optionally storing it in the storage.

Link copied to clipboard
fun <T, R> StateCallback<T, R, *>?.withStoreMap(value: R, currIndex: Int, handler: (Map<NodeParameterKey<T, *>, Any?>) -> ExpectationResult<T>): ExpectationResult<T>

Create a store map (using createStoreMap) and call the provided handler, returning an ExpectationResult.