RenderContextInterceptor

interface RenderContextInterceptor<P, S, O>

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

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

Intercepts calls to send on the BaseRenderContext.actionSink.

onRenderChild
Link copied to clipboard
open fun <CP, CO, CR> onRenderChild(child: Workflow<CP, CO, CR>, childProps: CP, key: String, handler: (CO) -> WorkflowAction<P, S, O>, proceed: (child: Workflow<CP, CO, CR>, CP, key: String, handler: (CO) -> WorkflowAction<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.

onRunningSideEffect
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.