AWAITALL (Promises, OnSuccess?, OnFailure?) AWAITALL (Promises; OnSuccess?; OnFailure?)

Promises

The promises.

OnSuccess

A formula fragment that is run when all promises have succeeded. The results returned by the promises are available as an array under the name Results . Use INDEX to retrieve individual results.

OnFailure

A formula fragment that is run when the first promise fails. An error is available under the name Error . Refer to the documentation for the action function returning the promise to learn what information is available on the error. The position of the promise that failed in the Promises array is available under the name Index .

Returns

A promise, which succeeds when and if all the given promises succeed and fails if a single one of those promises fails. If the promise succeeds, the returned value is an array of all the results returned by the promises. If the promise fails, the returned value is the error of the first promise to fail.

Waits for all promises to succeed before running an action. This function can only be used from an action formula. AWAITALL and other similar functions are used to take action when a promise succeeds or fails.

The first parameter to AWAITALL must be an array of promises . A function returning such a value promises to return a value at some point in the future, or at the very least indicate whether the operation the function started was successful. A promise either succeeds or fails, and it can only succeed or fail once.

AWAITALL runs the formula fragment given as its second parameter when all promises given to it succeed. This formula fragment has access to an array of results, under the name Results , which contains one result per promise of the array given to AWAITALL.

If any promise of the given array fails, the formula fragment given as the third parameter is run. It has access to two values, Error , which is the error returned by the promise that failed, and Index , which is the position of the promise that failed in the array.

fxEngine Shell Want this in your own terminal? A standalone version is coming. Get notified.
Loading fxEngine Shell