Async Class
Asynchronous command runner class.
Item Index
Properties
- commands static
Methods
_runAll
-
success
-
run
Command function for all mode.
Parameters:
-
success
Function -
run
[AsyncCommand]
_runAll
-
success
-
run
-
index
-
value
Command function for queue mode.
Parameters:
-
success
Function -
run
[AsyncCommand] -
index
Number -
value
Array
run
()
chainable
Execute the command function.
runAll
()
Async
static
Creates and runs an instance of Async in 'all' mode. This method accepts an unlimited number of arguments. Arguments can be command functions, AsyncCommand config objects, instances of AsyncCommand, instances of Async, or arrays containing any of the above.
Returns:
runAllWithConfig
()
Async
static
Creates and runs an instance of Async in 'all' mode. This method accepts an unlimited number of arguments. The first argument is a config object passed to the AsyncCommand constructor when instantiating dynamically. The rest of the arguments can be command functions, AsyncCommand config objects, instances of AsyncCommand, instances of Async, or arrays containing any of the above.
Returns:
runQueue
()
Async
static
Creates and runs an instance of Async in 'queue' mode. This method accepts an unlimited number of parameters. Parameters can be command functions, AsyncCommand config objects, instances of AsyncCommand, instances of Async, or arrays containing any of the above.
Returns:
runQueue
()
Async
static
Creates and runs an instance of Async in 'queue' mode. This method accepts an unlimited number of parameters. The first argument is a config object passed to the AsyncCommand constructor when instantiating dynamically. The rest of the arguments can be command functions, AsyncCommand config objects, instances of AsyncCommand, instances of Async, or arrays containing any of the above.
Returns:
Properties
commands
Object
static
This is a static object that stores named command definitions for repeat use. This object's keys are the names of commands. The values can either command functions or AsyncCommand config objects.
Attributes
args
Array
protected
The inherited args attribute is protected.
Default: []
Fires event argsChange
Fires when the value for the configuration attribute args
is
changed. You can listen for the event using the on
method if you
wish to be notified before the attribute's value has changed, or
using the after
method if you wish to be notified after the
attribute's value has changed.
Parameters:
-
e
EventFacadeAn Event Facade object with the following attribute-specific properties added:
completed
Boolean
Boolean value indicating the completed status of the command.
Default: false
Fires event completedChange
Fires when the value for the configuration attribute completed
is
changed. You can listen for the event using the on
method if you
wish to be notified before the attribute's value has changed, or
using the after
method if you wish to be notified after the
attribute's value has changed.
Parameters:
-
e
EventFacadeAn Event Facade object with the following attribute-specific properties added:
config
Object
A config object passed to the AsyncCommand constructor when instantiating dynamically.
Default: {}
Fires event configChange
Fires when the value for the configuration attribute config
is
changed. You can listen for the event using the on
method if you
wish to be notified before the attribute's value has changed, or
using the after
method if you wish to be notified after the
attribute's value has changed.
Parameters:
-
e
EventFacadeAn Event Facade object with the following attribute-specific properties added:
ctx
protected
The inherited ctx attribute is protected.
Fires event ctxChange
Fires when the value for the configuration attribute ctx
is
changed. You can listen for the event using the on
method if you
wish to be notified before the attribute's value has changed, or
using the after
method if you wish to be notified after the
attribute's value has changed.
Parameters:
-
e
EventFacadeAn Event Facade object with the following attribute-specific properties added:
error
Error value passed to the failure event.
Fires event errorChange
Fires when the value for the configuration attribute error
is
changed. You can listen for the event using the on
method if you
wish to be notified before the attribute's value has changed, or
using the after
method if you wish to be notified after the
attribute's value has changed.
Parameters:
-
e
EventFacadeAn Event Facade object with the following attribute-specific properties added:
failed
Boolean
Boolean value indicating the failed status of the command.
Default: false
Fires event failedChange
Fires when the value for the configuration attribute failed
is
changed. You can listen for the event using the on
method if you
wish to be notified before the attribute's value has changed, or
using the after
method if you wish to be notified after the
attribute's value has changed.
Parameters:
-
e
EventFacadeAn Event Facade object with the following attribute-specific properties added:
fn
Function
protected
The inherited fn attribute is protected.
Fires event fnChange
Fires when the value for the configuration attribute fn
is
changed. You can listen for the event using the on
method if you
wish to be notified before the attribute's value has changed, or
using the after
method if you wish to be notified after the
attribute's value has changed.
Parameters:
-
e
EventFacadeAn Event Facade object with the following attribute-specific properties added:
mode
String
Value indicating the run mode. Possible modes are:
- all
- This mode runs all commands. The commands might be completed out of order. The run completes once all commands have completed. The run fails if any command fails.
- queue
- This mode runs one command at a time. It waits for the first command to complete before moving on to the next one. The run completes when the last command has completed. The run fails if a command fails and the remaining commands are not run.
Default: 'queue'
Fires event modeChange
Fires when the value for the configuration attribute mode
is
changed. You can listen for the event using the on
method if you
wish to be notified before the attribute's value has changed, or
using the after
method if you wish to be notified after the
attribute's value has changed.
Parameters:
-
e
EventFacadeAn Event Facade object with the following attribute-specific properties added:
run
[AsyncCommand]
An array of AsyncCommands to run. Command functions, AsyncCommand config objects, and named command strings will get converted to instances of AsyncCommand.
Default: []
Fires event runChange
Fires when the value for the configuration attribute run
is
changed. You can listen for the event using the on
method if you
wish to be notified before the attribute's value has changed, or
using the after
method if you wish to be notified after the
attribute's value has changed.
Parameters:
-
e
EventFacadeAn Event Facade object with the following attribute-specific properties added:
started
Boolean
Boolean value indicating the started status of the command.
Default: false
Fires event startedChange
Fires when the value for the configuration attribute started
is
changed. You can listen for the event using the on
method if you
wish to be notified before the attribute's value has changed, or
using the after
method if you wish to be notified after the
attribute's value has changed.
Parameters:
-
e
EventFacadeAn Event Facade object with the following attribute-specific properties added:
value
Value passed to the success event.
Fires event valueChange
Fires when the value for the configuration attribute value
is
changed. You can listen for the event using the on
method if you
wish to be notified before the attribute's value has changed, or
using the after
method if you wish to be notified after the
attribute's value has changed.
Parameters:
-
e
EventFacadeAn Event Facade object with the following attribute-specific properties added:
Events
complete
Fired when the command function completes.
failure
protected
Fired when the command function fails.
Event Payload:
-
error
ObjectOptional error value.
start
protected
Fired when the command function starts.
success
protected
Fired when the command function succeeds.
Event Payload:
-
value
ObjectOptional return value from the command function.