API Docs for:
Show:

Async Class

Asynchronous command runner class.

Item Index

Methods

Properties

Methods

_runAll

(
  • success
  • run
)
protected

Command function for all mode.

Parameters:

_runAll

(
  • success
  • run
  • index
  • value
)
protected

Command function for queue mode.

Parameters:

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:

runQueueWithConfig

() 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 EventFacade
    An Event Facade object with the following attribute-specific properties added:
    • prevVal Any
      The value of the attribute, prior to it being set.
    • newVal Any
      The value the attribute is to be set to.
    • attrName String
      The name of the attribute being set.
    • subAttrName String
      If setting a property within the attribute's value, the name of the sub-attribute property being set.

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 EventFacade
    An Event Facade object with the following attribute-specific properties added:
    • prevVal Any
      The value of the attribute, prior to it being set.
    • newVal Any
      The value the attribute is to be set to.
    • attrName String
      The name of the attribute being set.
    • subAttrName String
      If setting a property within the attribute's value, the name of the sub-attribute property being set.

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 EventFacade
    An Event Facade object with the following attribute-specific properties added:
    • prevVal Any
      The value of the attribute, prior to it being set.
    • newVal Any
      The value the attribute is to be set to.
    • attrName String
      The name of the attribute being set.
    • subAttrName String
      If setting a property within the attribute's value, the name of the sub-attribute property being set.

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 EventFacade
    An Event Facade object with the following attribute-specific properties added:
    • prevVal Any
      The value of the attribute, prior to it being set.
    • newVal Any
      The value the attribute is to be set to.
    • attrName String
      The name of the attribute being set.
    • subAttrName String
      If setting a property within the attribute's value, the name of the sub-attribute property being set.

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 EventFacade
    An Event Facade object with the following attribute-specific properties added:
    • prevVal Any
      The value of the attribute, prior to it being set.
    • newVal Any
      The value the attribute is to be set to.
    • attrName String
      The name of the attribute being set.
    • subAttrName String
      If setting a property within the attribute's value, the name of the sub-attribute property being set.

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 EventFacade
    An Event Facade object with the following attribute-specific properties added:
    • prevVal Any
      The value of the attribute, prior to it being set.
    • newVal Any
      The value the attribute is to be set to.
    • attrName String
      The name of the attribute being set.
    • subAttrName String
      If setting a property within the attribute's value, the name of the sub-attribute property being set.

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 EventFacade
    An Event Facade object with the following attribute-specific properties added:
    • prevVal Any
      The value of the attribute, prior to it being set.
    • newVal Any
      The value the attribute is to be set to.
    • attrName String
      The name of the attribute being set.
    • subAttrName String
      If setting a property within the attribute's value, the name of the sub-attribute property being set.

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 EventFacade
    An Event Facade object with the following attribute-specific properties added:
    • prevVal Any
      The value of the attribute, prior to it being set.
    • newVal Any
      The value the attribute is to be set to.
    • attrName String
      The name of the attribute being set.
    • subAttrName String
      If setting a property within the attribute's value, the name of the sub-attribute property being set.

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 EventFacade
    An Event Facade object with the following attribute-specific properties added:
    • prevVal Any
      The value of the attribute, prior to it being set.
    • newVal Any
      The value the attribute is to be set to.
    • attrName String
      The name of the attribute being set.
    • subAttrName String
      If setting a property within the attribute's value, the name of the sub-attribute property being set.

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 EventFacade
    An Event Facade object with the following attribute-specific properties added:
    • prevVal Any
      The value of the attribute, prior to it being set.
    • newVal Any
      The value the attribute is to be set to.
    • attrName String
      The name of the attribute being set.
    • subAttrName String
      If setting a property within the attribute's value, the name of the sub-attribute property being set.

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 EventFacade
    An Event Facade object with the following attribute-specific properties added:
    • prevVal Any
      The value of the attribute, prior to it being set.
    • newVal Any
      The value the attribute is to be set to.
    • attrName String
      The name of the attribute being set.
    • subAttrName String
      If setting a property within the attribute's value, the name of the sub-attribute property being set.

Events

complete

Fired when the command function completes.

Event Payload:

  • error Object

    Optional error value.

  • failed Boolean

    Indicates the failed status of the command.

  • value Object

    Optional return value from the command function.

failure

protected

Fired when the command function fails.

Event Payload:

  • error Object

    Optional error value.

progress

Event Payload:

start

protected

Fired when the command function starts.

success

protected

Fired when the command function succeeds.

Event Payload:

  • value Object

    Optional return value from the command function.