//workflow/com.squareup.workflow1/WorkflowInterceptor/RenderContextInterceptor
RenderContextInterceptor¶
[jvm] 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:
- [RenderContextInterceptor.onActionSent](on-action-sent.md)
- [RenderContextInterceptor.onRunningSideEffect](on-running-side-effect.md)
E.g.:
override fun
onRender(
renderProps: P,
renderState: S,
proceed: (P, S, RenderContextInterceptor
) -> R,
session: WorkflowSession
): R = proceed(renderProps, renderState, object : RenderContextInterceptor
{
override fun onActionSent(
action: WorkflowAction
,
proceed: (WorkflowAction
) -> 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¶
Name | Summary |
---|---|
onActionSent | [jvm] Content open fun onActionSent(action: WorkflowAction<P, S, O>, proceed: (WorkflowAction<P, S, O>) -> Unit) More info Intercepts calls to send on the BaseRenderContext.actionSink. |
onRenderChild | [jvm] Content 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 More info 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 | [jvm] Content open fun onRunningSideEffect(key: String, sideEffect: suspend () -> Unit, proceed: (key: String, sideEffect: suspend () -> Unit) -> Unit) More info Intercepts calls to BaseRenderContext.runningSideEffect, allowing the interceptor to wrap or replace the sideEffect and its key. |