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
Set a new runner return behavior. The three types allowed are:
Behaviors:
Behavior Type | Description |
---|---|
SerializedArrayRunner.LAST_RETURN | All but the last resolved data is discarded. |
SerializedArrayRunner.ARRAY_RETURN | Each resolved data returned is pushed to an array and returned |
SerializedArrayRunner.CONCAT_ARRAY_RETURN | The resolved data is an array it's contents are concatenated to the final array for each iteration. |
- 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