BaseRenderContext
Facilities for a Workflow to interact with other Workflows and the outside world from inside a render
function.
Handling events from the UI
While a workflow's rendering can represent whatever you need it to, it is common for the rendering to contain the data for some part of your UI. In addition to shuttling data to the UI, the rendering can also contain functions that the UI can call to send events to the workflow.
E.g.
data class Rendering(
val radioButtonTexts: List<String>,
val onSelected: (index: Int) -> Unit
)
To create populate such functions from your render
method, you first need to define a WorkflowAction to handle the event by changing state, emitting an output, or both. Then, just pass a lambda to your rendering that instantiates the action and passes it to actionSink.send.
Performing asynchronous work
See runningWorker.
Composing children
See renderChild.
Inheritors
Properties
Accepts a single WorkflowAction, invokes that action by calling WorkflowAction.apply to update the current state, and optionally emits the returned output value if it is non-null.
Functions
Creates a function which builds a WorkflowAction from the given update function, and immediately passes it to actionSink. Handy for attaching event handlers to renderings.
Ensures child is running as a child of this workflow, and returns the result of its render
method.
Convenience alias of BaseRenderContext.renderChild for children that don't take props or emit output.
Convenience alias of BaseRenderContext.renderChild for workflows that don't emit output.
Convenience alias of BaseRenderContext.renderChild for workflows that don't take props.
Ensures sideEffect is running with the given key.
Ensures a LifecycleWorker is running. Since worker can't emit anything, it can't trigger any WorkflowActions.
Ensures worker is running. When the Worker emits an output, handler is called to determine the WorkflowAction to take. When the worker finishes, nothing happens (although another render pass may be triggered).