Futures on the JVM and promises in ClojureScript behind one set of functions so that code that waits for answers is written once. The functions take a value, a future or a promise alike.
Futures on the JVM and promises in ClojureScript behind one set of functions so that code that waits for answers is written once. The functions take a value, a future or a promise alike.
(all xs)(all f xs)The values of xs (each a value, a future or a promise) as a vector,
or the results of f on each of them. On the JVM it gives the vector
once every future has its value, and the futures run at once. In
ClojureScript it gives a promise of it.
With f every call is under way before any is waited for, e.g.
(all force [(delay (a!)) (delay (b!))]) makes two different calls at
once.
The values of `xs` (each a value, a future or a promise) as a vector, or the results of `f` on each of them. On the JVM it gives the vector once every future has its value, and the futures run at once. In ClojureScript it gives a promise of it. With `f` every call is under way before any is waited for, e.g. (all force [(delay (a!)) (delay (b!))]) makes two different calls at once.
(attempt f)The result of calling f as a map of its :value (in a future or a
promise). When f throws (or in ClojureScript rejects), the map has the
:error instead.
On the JVM each attempt runs on a future of its own, so several run at once. Errors count too (e.g. the StackOverflowError of deeply nested input), as anything thrown does in ClojureScript.
The result of calling `f` as a map of its :value (in a future or a promise). When `f` throws (or in ClojureScript rejects), the map has the :error instead. On the JVM each attempt runs on a future of its own, so several run at once. Errors count too (e.g. the StackOverflowError of deeply nested input), as anything thrown does in ClojureScript.
(explain e)The message of the failure e, with the messages of its causes that
add to it. The e is an exception, or another value that was thrown.
The client of the JDK and the fetch of Node give the reason that a connection failed in a cause, e.g. a java.net.ConnectException with the cause java.nio.channels.UnresolvedAddressException.
The message of the failure `e`, with the messages of its causes that add to it. The `e` is an exception, or another value that was thrown. The client of the JDK and the fetch of Node give the reason that a connection failed in a cause, e.g. a java.net.ConnectException with the cause java.nio.channels.UnresolvedAddressException.
(in-groups f n xs)The results of f on each of xs as a vector, n calls at a time, in
a future or a promise.
The results of `f` on each of `xs` as a vector, `n` calls at a time, in a future or a promise.
(iteration step!
&
{:keys [somef vf kf initk limit]
:or {somef some? vf identity kf identity limit ##Inf}
:as opts})The values that clojure.core/iteration gives for step! and opts as
a vector of at most :limit values (or in ClojureScript a promise of it).
The opts are the :somef, :vf, :kf and :initk of
clojure.core/iteration, and :limit. The step! function gives a value,
a future or a promise. So both platforms read an API that answers in
pages as the example of clojure.core/iteration does:
(iteration get-page! :initk "a" :vf :items :kf :next-page :limit 10)
The values that clojure.core/iteration gives for `step!` and `opts` as
a vector of at most :limit values (or in ClojureScript a promise of it).
The `opts` are the :somef, :vf, :kf and :initk of
clojure.core/iteration, and :limit. The `step!` function gives a value,
a future or a promise. So both platforms read an API that answers in
pages as the example of clojure.core/iteration does:
(iteration get-page! :initk "a" :vf :items :kf :next-page :limit 10)(some f xs)The first logical true result of f on the xs, or nil, as
clojure.core/some gives it. On the JVM it gives the result, and in
ClojureScript a promise of it.
Each call of f gives a value, a future or a promise, and the calls go
one at a time, so none is made after the first true result.
The first logical true result of `f` on the `xs`, or nil, as clojure.core/some gives it. On the JVM it gives the result, and in ClojureScript a promise of it. Each call of `f` gives a value, a future or a promise, and the calls go one at a time, so none is made after the first true result.
(then x f)The result of f on x once x is a value: at once when it's one or
when x (a future on the JVM or a promise in ClojureScript) has its
value.
The result of `f` on `x` once `x` is a value: at once when it's one or when `x` (a future on the JVM or a promise in ClojureScript) has its value.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |