Class: Step

Step(id, workflowId, name, dataopt, next, …custom)

Represents an executable unit of a workflow. Steps work best when they are atomically related to exactly one task. It is up to the user to define and implement what such a task might be. Examples of tasks can be fetching data from an endpoint or users submitting a form. Just make sure a step does not involve multiple tasks.

Constructor

new Step(id, workflowId, name, dataopt, next, …custom)

Creates a new step instance
Parameters:
Name Type Attributes Description
id string
workflowId string
name string
data object <optional>
optional data from start of the workflow
next string | number | undefined
custom object <repeatable>
all other properties that will be passed on to your custom handlers
Source:

Methods

cancel()

Sets the workflow state to 'cancelled' and wipes the data
Source:
Fires:
  • end - the workflow has ended,event: see state for the way it ended

complete()

Sets the workflow state to 'complete'
Source:
Fires:
  • end - the workflow has ended,event: see state for the way it ended

start()

Starts the step, changing its state from 'pending' to active. Note: This method is usually called by the workflow automatically. You should by default not have the need to call this method. Runs through all extensions. Extensions are caught in a separate Microtask (Promise.catch) and will not cause the step-start to cancel.
Source:
Fires:
  • started - when the step instance has successfully started (state became 'active')
Throws:
if the current state is other than "pending"
Type
TinyflowError

update(data)

Updates the step's data (hard-override!) Use it's existing data to merge
Parameters:
Name Type Description
data object
Source:
Fires:
  • event:update - the step's data has updated
Example
step.update({ foo: 1 }) // { foo: 1}
step.update({ bar: 2, ...step.data }) // { foo: 1, bar: 2 }