SessionWorkflow

An extension of StatefulWorkflow that gives initialState a CoroutineScope that corresponds with the lifetime of session driven by this Workflow.

A session begins the first time a parent passes a child Workflow of a particular type to renderChild with a particular key parameter. It ends when the parent executes render without making a matching renderChild call. The CoroutineScope that is passed to initialState is created when a session starts (when renderChild is first called), and cancelled when the session ends.

This API extension exists on StatefulWorkflow as well, but it is confusing because the version of initialState that does not have the CoroutineScope must also be implemented as it is an abstract fun, even though it would never be used. With this version, that confusion is removed and only the version of initialState with the CoroutineScope must be implemented.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard

Use a lazy delegate so that any ImpostorWorkflow.realIdentifier will have been computed before this is initialized and cached.

Link copied to clipboard

The computed WorkflowIdentifier for this Workflow. Any IdCacheable Workflow should call this and then store the value in the cachedIdentifier property so as to prevent the extra work needed to create the WorkflowIdentifier and look up the class name each time.

Link copied to clipboard

The WorkflowIdentifier that identifies this Workflow.

Functions

Link copied to clipboard

Convenience to create a WorkflowAction with parameter types matching those of the receiving StatefulWorkflow. The action will invoke the given lambda when it is applied.

Link copied to clipboard

Satisfies the Workflow interface by returning this.

Link copied to clipboard
override fun initialState(props: PropsT, snapshot: Snapshot?): StateT

Do not use this in favor of the version of initialState above that includes the Workflow's CoroutineScope

abstract override fun initialState(props: PropsT, snapshot: Snapshot?, workflowScope: CoroutineScope): StateT
Link copied to clipboard
Link copied to clipboard
open fun onPropsChanged(old: PropsT, new: PropsT, state: StateT): StateT

Called from RenderContext.renderChild instead of initialState when the workflow is already running. This allows the workflow to detect changes in props, and possibly change its state in response. This method is called only if the new props value is not == with the old.

Link copied to clipboard
abstract fun render(renderProps: PropsT, renderState: StateT, context: StatefulWorkflow.RenderContext<PropsT, StateT, OutputT, RenderingT>): RenderingT

Called at least once† any time one of the following things happens:

Link copied to clipboard
abstract fun snapshotState(state: StateT): Snapshot?

Called whenever the state changes to generate a new Snapshot of the state.