PROTOCOL
WorkflowObserver¶
public 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(_:)¶
func sessionDidBegin(
    _ session: WorkflowSession
)
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.
Parameters¶
| Name | Description | 
|---|---|
| session | The WorkflowSession that began. | 
sessionDidEnd(_:)¶
func sessionDidEnd(
    _ session: WorkflowSession
)
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.
Parameters¶
| Name | Description | 
|---|---|
| session | The WorkflowSession that ended. | 
workflowDidMakeInitialState(_:initialState:session:)¶
func workflowDidMakeInitialState<WorkflowType: Workflow>(
    _ workflow: WorkflowType,
    initialState: WorkflowType.State,
    session: WorkflowSession
)
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
Parameters¶
| Name | Description | 
|---|---|
| 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:)¶
func workflowWillRender<WorkflowType: Workflow>(
    _ workflow: WorkflowType,
    state: WorkflowType.State,
    session: WorkflowSession
) -> ((WorkflowType.Rendering) -> Void)?
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.
Parameters¶
| Name | Description | 
|---|---|
| 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. | 
workflowDidChange(from:to:state:session:)¶
func workflowDidChange<WorkflowType: Workflow>(
    from oldWorkflow: WorkflowType,
    to newWorkflow: WorkflowType,
    state: WorkflowType.State,
    session: WorkflowSession
)
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.
Parameters¶
| Name | Description | 
|---|---|
| oldWorkflow | The previous Workflow | 
| newWorkflow | The new Workflow | 
| state | The state the update has occurred. | 
| session | The WorkflowSession corresponding to the backing WorkflowNode. | 
workflowDidReceiveAction(_:workflow:session:)¶
func workflowDidReceiveAction<Action: WorkflowAction>(
    _ action: Action,
    workflow: Action.WorkflowType,
    session: WorkflowSession
)
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.
Parameters¶
| Name | Description | 
|---|---|
| action | The action that was received. | 
| session | The WorkflowSession corresponding to the backing WorkflowNode. | 
workflowWillApplyAction(_:workflow:state:session:)¶
func workflowWillApplyAction<Action: WorkflowAction>(
    _ action: Action,
    workflow: Action.WorkflowType,
    state: Action.WorkflowType.State,
    session: WorkflowSession
) -> ((Action.WorkflowType.State, Action.WorkflowType.Output?) -> Void)?
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.
Parameters¶
| Name | Description | 
|---|---|
| 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. |