Tasks
Object that holds actions and promises, which are executed at specific events.
Inside Mebo tasks are used by the Session.wrapup to hold actions and promises that are triggered when a Session is about to be terminated (Session.finalize).
Constructor Summary
Public Constructor | ||
public |
Creates a new instance |
Method Summary
Public Methods | ||
public |
Adds an action to the tasks |
|
public |
addWrappedPromise(wrappedPromise: function, options: Object) Adds a wrapped promise to the tasks |
|
public |
clear() Resets the tasks by cleaning all actions and promises |
|
public |
Returns a list sorted by priority and inclusion order about the actions and promises that are executed through execute |
|
public |
Tells if there are no tasks |
|
public |
Executes the actions and promises inside of the tasks (provided by contents). |
Public Constructors
Public Methods
public addAction(action: Action, options: Object) source
Adds an action to the tasks
runOnlyOnce
can be used to avoid the execution of an action that may be triggered
multiple times across nested actions where ideally it should be executed only once,
it's done by using the action's id (Action.id).
Params:
Name | Type | Attribute | Description |
action | Action | action instance that should be executed in the wrap up |
|
options | Object | custom options |
|
options.runOnlyOnce | boolean |
|
tells if the action should be ignore in case it has already been executed previously (it's done by matching the Action.id) |
options.priority | number |
|
tells the priority of the action, this affects the execution order where a lower numeric value means a higher priority. |
public addWrappedPromise(wrappedPromise: function, options: Object) source
Adds a wrapped promise to the tasks
Params:
Name | Type | Attribute | Description |
wrappedPromise | function | function that should return a promise, ex:
|
|
options | Object | custom options |
|
options.priority | number |
|
tells the priority of the action, this affects the execution order where a lower numeric value means a higher priority. |
public async contents(actions: boolean, promises: boolean): Promise<Array> source
Returns a list sorted by priority and inclusion order about the actions and promises that are executed through execute
public async run(): Promise<Array> source
Executes the actions and promises inside of the tasks (provided by contents). All tasks get executed even if an error occurs during the execution of an specific task. In case this method is triggered multiple times it ensures each task is only executed once.
Failed tasks are reported through an exception raised after all tasks have been executed,
this error provides the taskMeboErrors
member that contains a list about the errors raised
during the execution of the tasks.