remember

inline fun <ResultT> BaseRenderContext<*, *, *>.remember(key: String, vararg inputs: Any?, noinline calculation: () -> ResultT): ResultT(source)

Remember the value calculated by the calculation lambda. The calculation will be run the first time, and on any subsequent render pass where the inputs have changed.

The StatefulWorkflow.RenderContext.eventHandler and StatelessWorkflow.RenderContext.eventHandler functions use this mechanism to provide lambdas whose identity are stable across multiple render passes.

Parameters

key

used to distinguish between calculations of the same type

inputs

any inputs to the calculation. The calculation will only rerun if any of these inputs changes, so make sure you use the exact list of inputs for the calculation here.

calculation

a lambda that performs the calculation based on the inputs.

Throws

if key has already been used in the current render call for a lambda of the same shape