workflow-it
Run async tasks in a series of steps.
Unlike Promise.all
, which runs all tasks in parallel, workflowit
will run each task in sequence they were added to the workflow object.
This is useful for when you are tying to put a bunch of tasks back to back without each one stepping over each other.
Okay, tell me more.
With workflowit
, you create a Workflow
object, and add Step
s which represent your task.
The function you pass into your step can optionally return a promise.
{ tosWgt;} { return service;}// The task function is passed the step and workflow object. { welcomeWgt;} // Setup the workflow.var Workflow = ; // Create workflow and add steps.var wf = "startup" ; // You can also provide steps directly in the constructorvar wf = "startup" "tos" showTermsOfService "rn" showReleaseNotes "welcome" showWelcome; // Later....wf;
In the above example, rn
won't run until tos
promise has resolved, similarly, welcome
won't run until rn
has completed.
You can listen for events.
wf
All events can return a promise.
The Worflow.Step
object emits an exec
event when it has complted running.
step
Workflow
and Workflow.Step
.
You can of course extend, swap