package brr

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Jv.PromiseSource

JavaScript promise support.

In bindings do not use this directly use Fut.

Sourcetype t = jv

The type for JavaScript promises.

Sourceval create : (('a -> unit) -> ('b -> unit) -> unit) -> t

create (fun res rej -> ...) is a promise that can be resolved with res and rejected with rej. Note that res has a weird semantics see resolve for details.

Sourceval resolve : 'a -> t

resolve v is a promise that resolve with v. Warning. this is not a monadic return it also joins. Use Fut for a sound typed semantics of promises.

Sourceval reject : 'a -> t

reject v is a promise that rejects with v.

Sourceval await : t -> ('a -> unit) -> unit

await p k waits for p to resolve and continues with k.

Sourceval bind : t -> ('a -> t) -> t

bind p fn binds p's resolution to function fn.

Sourceval then' : t -> ('a -> t) -> ('b -> t) -> t

then' p res rej binds p's resolution to res and p's rejection to rej.

Sourceval all : jv -> t

all arr is a promise that resolves all the promises in the array arr to an array of values.

OCaml

Innovation. Community. Security.