Futures on the JVM and promises in ClojureScript behind one set of functions, so that you write code that waits for answers only 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 you write code that waits for answers only 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 (in ClojureScript a promise of
it). On the JVM it returns once every future has its value, and the
futures run at once.
With f, every call is under way before it waits for any, e.g.
(all force [(delay (a!)) (delay (b!))]) runs a! and b! 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 (in ClojureScript a promise of it). On the JVM it returns once every future has its value, and the futures run at once. With `f`, every call is under way before it waits for any, e.g. (all force [(delay (a!)) (delay (b!))]) runs a! and b! at once.
(attempt f)The result of calling f as a map of its :value, in a future on the
JVM and a promise in ClojureScript. 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. a StackOverflowError from deeply nested input, as anything thrown does in ClojureScript.
The result of calling `f` as a map of its :value, in a future on the JVM and a promise in ClojureScript. 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. a StackOverflowError from 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 JDK's client and Node's fetch put 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 JDK's client and Node's fetch put 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, with n calls at a time
(in ClojureScript a promise of it).
The results of `f` on each of `xs` as a vector, with `n` calls at a time (in ClojureScript a promise of it).
(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 returns for step! and opts,
as a vector of at most :limit values (in ClojureScript a promise of it).
The opts are the :somef, :vf, :kf and :initk of
clojure.core/iteration, and :limit. The step! function returns a
value, a future or a promise, so the same code pages through an API on
both platforms, as in the example of clojure.core/iteration:
(iteration get-page! :initk "a" :vf :items :kf :next-page :limit 10)
The values that clojure.core/iteration returns for `step!` and `opts`,
as a vector of at most :limit values (in ClojureScript a promise of it).
The `opts` are the :somef, :vf, :kf and :initk of
clojure.core/iteration, and :limit. The `step!` function returns a
value, a future or a promise, so the same code pages through an API on
both platforms, as in the example of clojure.core/iteration:
(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 returns it (in ClojureScript a promise of it).
Each call of f returns a value, a future or a promise. The calls go
one at a time, so it makes none after the first true result.
The first logical true result of `f` on the `xs`, or nil, as clojure.core/some returns it (in ClojureScript a promise of it). Each call of `f` returns a value, a future or a promise. The calls go one at a time, so it makes none after the first true result.
(then x f)The result of f on the value of x (in ClojureScript a promise of
it). The x is a value, a future on the JVM or a promise in
ClojureScript.
The result of `f` on the value of `x` (in ClojureScript a promise of it). The `x` is a value, a future on the JVM or a promise in ClojureScript.
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 |