Promises and futures largely compatible with the clojure.core api.
The main difference is, that [[cljs.core/deref]]/@
cannot be used
on promises and futures. Instead async-deref
can be used to work
with the respective results asynchronously. Also, futures may do
asynchronous operations, by returning a core/promise
.
Note that [[cljs.core/realized?]] works on both promises and futures.
Promises and futures largely compatible with the clojure.core api. The main difference is, that [[cljs.core/deref]]/`@` cannot be used on promises and futures. Instead [[async-deref]] can be used to work with the respective results asynchronously. Also, futures may do asynchronous operations, by returning a [[core/promise]]. Note that [[cljs.core/realized?]] works on both promises and futures.
(async-deref v)
(async-deref v timeout-ms timeout-val)
Returns a js/Promise of the result of the given promise or future, optionally with a timeout.
Returns a js/Promise of the result of the given promise or future, optionally with a timeout.
(deliver p v)
Delivers the supplied value to the promise, releasing any pending derefs. A subsequent call to deliver on a promise will have no effect.
Delivers the supplied value to the promise, releasing any pending derefs. A subsequent call to deliver on a promise will have no effect.
(future & body)
Takes a body of expressions and yields a future object that will
evaluate the body later, and will cache the result and return it on
all subsequent calls to async-deref
.
Takes a body of expressions and yields a future object that will evaluate the body later, and will cache the result and return it on all subsequent calls to [[async-deref]].
(future-call thunk)
Takes a function of no args and yields a future object that will
invoke the function later, and will cache the result and return it on
all subsequent calls to async-deref
.
Takes a function of no args and yields a future object that will invoke the function later, and will cache the result and return it on all subsequent calls to [[async-deref]].
(future-cancel f)
Cancels the future, if possible.
Cancels the future, if possible.
(future-cancelled? f)
Returns true if the given future is cancelled.
Returns true if the given future is cancelled.
(future-done? f)
Returns true if the given future is done.
Returns true if the given future is done.
(future? v)
Returns true if v
is a future.
Returns true if `v` is a future.
(-async-deref this)
Returns a js/Promise resolving to the value of this once it is available.
Returns a js/Promise resolving to the value of this once it is available.
(-async-deref-with-timeout this msec timeout-val)
Returns a js/Promise resolving to the value of this once it is available, or to the given value after a timeout of the given number of milliseconds.
Returns a js/Promise resolving to the value of this once it is available, or to the given value after a timeout of the given number of milliseconds.
(promise)
Returns a promise object that can be read with async-deref
, and set,
once only, with deliver
.
Returns a promise object that can be read with [[async-deref]], and set, once only, with [[deliver]].
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close