RenderContextInterceptor

Provides hooks for intercepting calls to a BaseRenderContext, to be used from onRender.

For use by onRender methods that want to hook into action and side effect events. See documentation on methods for more information about the individual hooks:

E.g.:

override fun <P, S, O, R> onRender(
renderProps: P,
renderState: S,
proceed: (P, S, RenderContextInterceptor<P, S, O>) -> R,
session: WorkflowSession
): R = proceed(renderProps, renderState, object : RenderContextInterceptor<P, S, O> {
override fun onActionSent(
action: WorkflowAction<P, S, O>,
proceed: (WorkflowAction<P, S, O>) -> Unit
) {
log("Action sent: $action")
proceed(action)
}

override fun onRunningSideEffect(
key: String,
sideEffect: suspend () -> Unit,
proceed: (key: String, sideEffect: suspend () -> Unit) -> Unit
) {
proceed(key) {
log("Side effect started: $key")
sideEffect()
log("Side effect ended: $key")
}
}
})

Functions

Link copied to clipboard
open fun onActionSent(action: <Error class: unknown class><P, S, O>, proceed: (<Error class: unknown class><P, S, O>) -> Unit)

Intercepts calls to Sink.send on the BaseRenderContext.actionSink.

Link copied to clipboard
open fun <CResult> onRemember(key: String, resultType: KType, inputs: Array<out Any?>, calculation: () -> CResult, proceed: (key: String, resultType: KType, inputs: Array<out Any?>, calculation: () -> CResult) -> CResult): CResult
Link copied to clipboard
open fun <CP, CO, CR> onRenderChild(child: <Error class: unknown class><CP, CO, CR>, childProps: CP, key: String, handler: (CO) -> <Error class: unknown class><P, S, O>, proceed: (<Error class: unknown class><CP, CO, CR>, childProps: CP, key: String, handler: (CO) -> <Error class: unknown class><P, S, O>) -> CR): CR

Intercepts calls to BaseRenderContext.renderChild, allowing the interceptor to wrap or replace the child Workflow, its childProps, key, and the handler function to be applied to the child's output.

Link copied to clipboard
open fun onRunningSideEffect(key: String, sideEffect: suspend () -> Unit, proceed: (key: String, sideEffect: suspend () -> Unit) -> Unit)

Intercepts calls to BaseRenderContext.runningSideEffect, allowing the interceptor to wrap or replace the sideEffect and its key. This could be used to prevent a side effect from running, or to augment it with further effects.