TransformStateCallback

class TransformStateCallback<T, R, U>(transformer: (R) -> U) : StateCallback<T, R, U>

An implementation of StateCallback that transforms incoming state using the provided transformer.

Parameters

T

The context type (see NodeParameterKey for details)

R

The initial type of the state, as input into this callback

U

The type of the output of this transformer, i.e. the type of the returned state.

Constructors

Link copied to clipboard
constructor(transformer: (R) -> U)

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): U

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.