package promise_jsoo
Install
Dune Dependency
Authors
Maintainers
Sources
md5=dc3d7930cdebdbaa5f01ffce36c9ccd4
sha512=250499b2f6db7b7708a591cb468acfd0e81774506cc24d2d3cb1387bcf033b2f4edd58ff09b10623dce70ed0e3734a947a341f238da9567138ae3112af999246
doc/promise_jsoo/Promise/index.html
Module Promise
Source
The Promise object represents the eventual completion (or failure) of an asynchronous operation, and its resulting value.
Type for errors returned by reject
Creates a new Promise object. The constructor is primarily used to wrap functions that do not already support promises.
Instance Methods
Appends a rejection handler callback to the promise, and returns a new promise resolving to the return value of the callback if it is called, or to its original fulfillment value if the promise is instead fulfilled.
Appends fulfillment and rejection handlers to the promise, and returns a new promise resolving to the return value of the called handler, or to its original settled value if the promise was not handled (i.e. if the relevant handler fulfilled
or rejected
is not a function).
Appends a handler to the promise, and returns a new promise that is resolved when the original promise is resolved. The handler is called when the promise is settled, whether fulfilled or rejected.
Static Methods
Wait for all promises to be resolved, or for any to be rejected.
If the returned promise resolves, it is resolved with an aggregating array of the values from the resolved promises ,in the same order as defined in the iterable of multiple promises.
If it rejects, it is rejected with the reason from the first promise in the iterable that was rejected.
Specialization of all
for a tuple of 3 promises
Wait until any of the promises is resolved or rejected.
If the returned promise resolves, it is resolved with the value of the first promise in the iterable that resolved.
If it rejects, it is rejected with the reason from the first promise that was rejected.
Returns a new Promise
object that is resolved with the given value. If the value is a thenable (i.e. has a then
method), the returned promise will "follow" that thenable, adopting its eventual state; otherwise the returned promise will be fulfilled with the value.
Generally, if you don't know if a value is a promise or not, Promise.resolve value
it instead and work with the return value as a promise.
Supplemental API
Functions that are not part of the original JS Promise API, but are useful for writing OCaml code