An array containing the following values:
0 (string): the step name that just completed 1 (string): the step name to transition to 2 (iteratee): optional predicate function to run to determine if the transition should occur
An array of ProcessTransition array instances.
Returns a method you can invoke to begin a complex asynchronous process. The order of actions taken is determined using the ProcessLogic object passed as the last argument. You can use the built-in dependencies and transitions logic factories to create this object for you, or supply your own logic to create custom process behaviors.
The name of the process to run.
An interable collection (e.g. Set, array, or ModelCollection) of Actions to run.
The logic that determines how to start and continue a process.
A method you can invoke to begin the process. The arguments will depend in part on the ProcessLogic object you passed.
Creates a ProcessLogic instance that can be passed to the process method. When started, the process will use the dependency map to determine which actions can be invoked immediately (having no dependencies) and which should be run when their dependent actions have completed.
This method results in the process running like a workflow, with some actions run in parallel and the execution order of actions dependent upon the stated dependencies.
The dependency map that should be used to determine the initial and follow-up actions to invoke in this process.
A ProcessLogic instance that process can use to determine how to run the ModelCollection actions it was provided.
Utility method to run a single Action in isolation. This method is used internally by process but is made available publicly for unusual situations.
NOTE: The success and failure methods will not be run using this method since their invocation depends on whether or not a collection of Actions has completed successfully. If you want to invoke the success and failure methods, you should do so manually. See the example for details.
The Action whose methods should be invoked.
The context accessed using this
within an action method.
Whether to run the Action's init method.
Creates a ProcessLogic instance that can be passed to the process method. When started, the process will use the transition criteria to determine which actions can be invoked based on the current set of conditions as passed to the start method or through calls to update.
NOTE: A process using transitions logic will not stop until and unless one of the following occurs:
stop()
methodcancel()
methodThis method results in the process running like a state machine, with one action allowed to run at any time and the next action determined using the current conditions and the given transition logic.
The transitions that should be used to determine the initial and follow-up actions to invoke in this process.
A ProcessLogic instance that process can use to determine how to run the ModelCollection actions it was provided.
Provides utilities for running complex, multi-step asynchronous processes.
Overview
A process consists of 2 things:
This abstraction enables both workflow-style processes (multiple steps running in parallel, with some steps dependent on the completion of earlier steps) as well as state machine-style processes (one state active at a time, with the next state determined by examining the process' current set of conditions).
You can even set up custom process logic by providing your own ProcessLogic instance to the process method. See the example here.
Action Methods
Each Action in a process can implement methods that the process will invoke at the appropriate time. These methods can be broken down into 2 categories:
The "exec" methods are run when the action is invoked. These include init, execute and retry.
The "post-exec" methods are run after the process completes. These include rollback, failure, and success.
IMPORTANT! The post-exec methods are run in parallel and at the same time that the ExecutionPromise returned by ProcessStart is resolved or rejected, meaning there is no guaranteed order between your process callbacks and your actions' post-exec methods.