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

Promises

The promises.

OnSuccess

A formula fragment that is run when a promise succeeds. If the promise returns a result, this result is available under the name Result . The position of the promise that succeeded in the Promises array is available under the name Index .

OnFailure

A formula fragment that is run when a 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. The returned promise behaves identically to the promise returned from AWAITALL.

Waits for multiple promises to return responses before running actions. This function can only be used from an action formula. AWAITMANY and other similar functions are used to take action when a promise succeeds or fails.

The first parameter to AWAITMANY 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.

AWAITMANY enables promises to be handled, one at a time. The second parameter to this function is a formula fragment which is run in response to the given promises succeeding. Similarly, the third parameter is a formula fragument which is run in response to the given promises failing.

If there are five promises in the array and three of those promises succeed and two fail, the second parameter is invoked three times and the third parameter is invoked twice.

When a formula fragment is run, it has access to the position of the promise which succeeded or failed in the array of promises under the name Index .

As with AWAIT, the formula fragment given as the second parameter has access to the result of the promise under the name Result . Finally, the formula fragment given as the third parameter has access to a value named Error with more information on what went wrong.

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