Construct a Future.
The supplied fn argument will be discarded once run, so any data referenced by it can be freed by the GC.
The function performing the future calculation
true if the calculation should be delayed until an explicit call to eval
.
Attaches a callback for only the rejection of the Promise.
The callback to execute when the Promise is rejected.
A Promise for the completion of the callback.
Perform the calculation supplied on construction. Takes arguments like {@link Promise#then}. Any pending
handlers from Promise.then()
, Promise.catch()
, or Promise.finally()
will be also be
handled as normal.
eval is run synchronously if the supplied function is synchronous. The result is not wrapped in a Promise
,
but will be a Promise
if that's what the supplied function returns. The supplied handlers are not run synchronously.
Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The resolved value cannot be modified from the callback.
The callback to execute when the Promise is settled (fulfilled or rejected).
A Promise for the completion of the callback.
This runs {@link Promise#then} normally. If the supplied future function has not been run, runs that first, unless delay was supplied as truthy, or unless neither onfullfilled or onrejected was supplied.
Creates a Promise that is resolved with an array of results when all of the provided Promises resolve, or rejected when any Promise is rejected.
An iterable of Promises.
A new Promise.
Creates a Promise that is resolved with an array of results when all of the provided Promises resolve, or rejected when any Promise is rejected.
An array of Promises.
A new Promise.
Creates a Promise that is resolved with an array of results when all of the provided Promises resolve or reject.
An array of Promises.
A new Promise.
Creates a Promise that is resolved with an array of results when all of the provided Promises resolve or reject.
An array of Promises.
A new Promise.
The any function returns a promise that is fulfilled by the first given promise to be fulfilled, or rejected with an AggregateError containing an array of rejection reasons if all of the given promises are rejected. It resolves all elements of the passed iterable to promises as it runs this algorithm.
An array or iterable of Promises.
A new Promise.
The any function returns a promise that is fulfilled by the first given promise to be fulfilled, or rejected with an AggregateError containing an array of rejection reasons if all of the given promises are rejected. It resolves all elements of the passed iterable to promises as it runs this algorithm.
An array or iterable of Promises.
A new Promise.
Creates a Promise that is resolved or rejected when any of the provided Promises are resolved or rejected.
An iterable of Promises.
A new Promise.
Creates a Promise that is resolved or rejected when any of the provided Promises are resolved or rejected.
An array of Promises.
A new Promise.
Creates a new rejected promise for the provided reason.
The reason the promise was rejected.
A new rejected Promise.
Creates a new resolved promise.
A resolved promise.
Creates a new resolved promise for the provided value.
A promise.
A promise whose internal state matches the provided promise.
Generated using TypeDoc
A Future is a variant of a Promise that takes a function to start execution at a later point, when the value is desired. It can be used to delay a computation, or to avoid it entirely if not needed.
By default, the computation begins when the first onfulfilled handler is added with then, but if the delay parameter is supplied as
true
an explicit call to the eval method is required.This can be used to delay initiating a computation until a certain elapsed time (using delay) or until some event has occurred.