Library
Module
Module type
Parameter
Class
Class type
The Promise object represents the eventual completion (or failure) of an asynchronous operation, and its resulting value.
type error = Ojs.t
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.
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.
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.
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.
val resolve : 'a -> 'a t
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.
Functions that are not part of the original JS Promise API, but are useful for writing OCaml code
module Syntax : sig ... end
module Option : sig ... end
module Result : sig ... end
module Array : sig ... end
module List : sig ... end