Skip to content

PROTOCOL

WorkflowObserver

The WorkflowObserver protocol provides an interface to receive updates during the runtime’s execution loop. All requirements are optional, and no-ops are provided by default.

Methods

sessionDidBegin(_:)

Indicates the start of a WorkflowSession, which tracks the life of the underlying WorkflowNode used to provide renderings for a given Workflow type and rendering key. - Parameter session: The WorkflowSession that began.

sessionDidEnd(_:)

Marks the end of a WorkflowSession, indicating that the corresponding WorkflowNode has been removed from the tree of Workflows. - Parameter session: The WorkflowSession that ended.

workflowDidMakeInitialState(_:initialState:session:)

Indicates a Workflow produced its initial state value. - Parameters: - workflow: The Workflow that just produced its initial state. - initialState: The State that was created. - session: The WorkflowSession corresponding to the backing WorkflowNode

workflowWillRender(_:state:session:)

Called before a Workflow is queried for its latest Rendering. - Parameters: - workflow: The Workflow that is about to be render. - state: The corresponding State that will be used during the render call. - session: The WorkflowSession corresponding to the backing WorkflowNode. - Returns: An optional closure to be called immediately after the new Rendering is produced, which takes the rendering as the only parameter.

workflowDidChange(from:to:state:session:)

Called after an existing Workflow is updated. - Parameters: - oldWorkflow: The previous Workflow - newWorkflow: The new Workflow - state: The state after the update has occurred. - session: The WorkflowSession corresponding to the backing WorkflowNode.

workflowDidReceiveAction(_:workflow:session:)

Called after a WorkflowAction is received, but before it has been handled and propagated up the tree. - Parameters: - action: The action that was received. - session: The WorkflowSession corresponding to the backing WorkflowNode.

workflowWillApplyAction(_:workflow:state:session:)

Called when a WorkflowAction will be applied to its corresponding Workflow’s State - Parameters: - action: The action that will be applied. - workflow: The action’s corresponding Workflow. - state: The state to which the action will be applied. - session: The WorkflowSession corresponding to the backing WorkflowNode. - Returns: An optional closure to be called immediately after the action is applied to the State, and an optional Output has been produced. The closure takes the updated state and optional output as its arguments.