Class: SerializedArrayRunner

SerializedArrayRunner

Class for serially executing functions returning promises, with each call passing an element of the array as an argument.

Constructor

new SerializedArrayRunner(returnBehavioropt)

Create the class and optionaly set the behavior. See Behaviors for a list of allowed types.
Parameters:
Name Type Attributes Description
returnBehavior string <optional>
Optional parameter to set the return behavior. The default value is SerializedArrayRunner.LAST_RETURN.
Source:

Members

(static) ARRAY_RETURN

Used to set the behavior to array return. The data from resolved promises for all will be pushed into an array and returned with the resolved promise.
Source:

(static) CONCAT_ARRAY_RETURN

Used to set the behavior to concatenated array return. The data from resolved promises for is expected to be an array. Each array returned is concatenated and returned with the resolved promise.
Source:

(static) LAST_RETURN

Used to set the behavior to last return. The data from resolved promises for all but the last call will be discarded.
Source:

behaviorType

Retrieve the value of the current return behavior
Source:

behaviorType

Source:

Methods

run(arrayToIterate, functionToCall, scope, …args) → {Promise}

Iterates through the array calling the provided function and waits for the resolution before proceeding. Returns a promise when the iteration is complete. The data resolved depends on the supplied function return data and the configured return behavior
Parameters:
Name Type Attributes Description
arrayToIterate Array The array who's elements are passed to the function.
functionToCall function The function that gets call. It must return a promise. The first parameter is the current array element.
scope object The scope for the function to be called in. Necessary if the function is class method.
args * <repeatable>
Zero or more arguments to send to the function. Note that the first argument here, is the fourth argument to the called function.
Source:
Returns:
A resolved promise is returned if all function calls resolve.
Type
Promise