Liking cljdoc? Tell your friends :D

promesa.core


aletclj/smacro

A backward compatibility alias for let.

A backward compatibility alias for `let`.
raw docstring

allclj/s

(all promises)

Given an array of promises, return a promise that is fulfilled when all the items in the array are fulfilled.

Example:

(-> (all [(promise :first-promise) (promise :second-promise)] (then (fn [[first-result second-result]])) (println (str first-result ", " second-result)

Will print out :first-promise, :second-promise.

If at least one of the promises is rejected, the resulting promise will be rejected.

Given an array of promises, return a promise
that is fulfilled  when all the items in the
array are fulfilled.

Example:

(-> (all [(promise :first-promise)
          (promise :second-promise)]
    (then (fn [[first-result second-result]]))
     (println (str first-result ", " second-result)

Will print out
:first-promise, :second-promise.

If at least one of the promises is rejected, the resulting promise will be
rejected.
raw docstring

anyclj/s

(any promises)
(any promises default)

Given an array of promises, return a promise that is fulfilled when first one item in the array is fulfilled.

Given an array of promises, return a promise that is fulfilled when
first one item in the array is fulfilled.
raw docstring

bindclj/s

(bind p f)
(bind p f e)

Backward compatibility alias to then.

Backward compatibility alias to `then`.
raw docstring

cancel!clj/s

(cancel! p)

Cancel the promise.

Cancel the promise.
raw docstring

cancelled?clj/s

(cancelled? v)

Return true if v is a cancelled promise.

Return true if `v` is a cancelled promise.
raw docstring

catchclj/s

(catch p f)
(catch p pred-or-type f)

Executes f when the promise p is rejected. Returns a promise resolved with the return value of f function handler.

Executes `f` when the promise `p` is rejected. Returns a promise
resolved with the return value of `f` function handler.
raw docstring

chainclj/s

(chain p f)
(chain p f & fs)

Chain variable number of computations to be executed serially. Analogous to then that accepts variable number of functions.

Chain variable number of computations to be executed
serially. Analogous to `then` that accepts variable number of
functions.
raw docstring

chain'clj/s

(chain' p f)
(chain' p f & fs)

Chain variable number of computations to be executed serially. Unlike chain does not flattens the return value of each step (probably this is more performant than chain).

Chain variable number of computations to be executed serially. Unlike
`chain` does not flattens the return value of each step (probably
this is more performant than `chain`).
raw docstring

createclj/s

(create f)
(create f executor)

Create a promise instance from a factory function. If an executor is provided, the factory will be executed in the provided executor.

A factory function looks like (fn [resolve reject] (resolve 1)).

Create a promise instance from a factory function. If an executor is
provided, the factory will be executed in the provided executor.

A factory function looks like `(fn [resolve reject] (resolve 1))`.
raw docstring

deferredclj/s

(deferred)

Creates an empty promise instance.

Creates an empty promise instance.
raw docstring

deferred?clj/s

(deferred? v)

Return true if v is a promise instance (alias to promise?.

Return true if `v` is a promise instance (alias to `promise?`.
raw docstring

delayclj/s

(delay t)
(delay t v)
(delay t v scheduler)

Given a timeout in miliseconds and optional value, returns a promise that will fulfilled with provided value (or nil) after the time is reached.

Given a timeout in miliseconds and optional
value, returns a promise that will fulfilled
with provided value (or nil) after the
time is reached.
raw docstring

do!clj/smacro

(do! & exprs)

Execute potentially side effectful code and return a promise resolved to the last expression. Always awaiting the result of each expression.

Execute potentially side effectful code and return a promise
resolved to the last expression. Always awaiting the result of each
expression.
raw docstring

done?clj/s

Returns true if promise p is already done.

Returns true if promise `p` is already done.
raw docstring

errclj/s

A short alias for error function.

A short alias for `error` function.
raw docstring

errorclj/s

(error f p)
(error f type p)

Same as catch but with parameters inverted.

Same as `catch` but with parameters inverted.
raw docstring

extractclj/s

(extract p)

Returns the current promise value.

Returns the current promise value.
raw docstring

finallyclj/s

(finally p f)
(finally p f executor)

Attach a potentially side-effectful handler to promise that will be executed independently if promise is resolved or rejected.

Returns the original promise and the return value of f function is ignored.

Attach a potentially side-effectful handler to promise that will be
executed independently if promise is resolved or rejected.

Returns the original promise and the return value of `f` function is
ignored.
raw docstring

futureclj/smacro

(future & body)

Analogous to clojure.core/future that returns a promise instance instead of the Future. Usefull for execute synchronous code in a separate thread (also works in cljs).

Analogous to `clojure.core/future` that returns a promise instance
instead of the `Future`. Usefull for execute synchronous code in a
separate thread (also works in cljs).
raw docstring

handleclj/s

(handle p f)
(handle p f executor)

Executes f when the promise p is resolved or is rejected. Returns a promise resolved with the return value of f function.

Executes `f` when the promise `p` is resolved or is rejected. Returns
a promise resolved with the return value of `f` function.
raw docstring

letclj/smacro

(let bindings & body)

A let alternative that always returns promise and waits for all the promises on the bindings.

A `let` alternative that always returns promise and waits for
all the promises on the bindings.
raw docstring

loopclj/smacro

(loop bindings & body)

Analogous to clojure.core/loop.

Analogous to `clojure.core/loop`.
raw docstring

mapclj/s

(map f p)
(map executor f p)

Chains a computation f (function) to be executed when the promise p is successfully resolved.

Unlike then this does not performs automatic promise flattening. This is designed to be used with ->>.

Chains a computation `f` (function) to be executed when the promise
`p` is successfully resolved.

Unlike `then` this does not performs automatic promise flattening.
This is designed to be used with `->>`.
raw docstring

mapcatclj/s

(mapcat f p)
(mapcat executor f p)

Chains a computation f (function) to be executed when the promise p is successfully resolved. always expecting that f returns a promise that will be automatically unwrapped.

This is just a stricter version of then with reversed arguments in the same way as map.

This is designed to be used with ->>.

Chains a computation `f` (function) to be executed when the promise
`p` is successfully resolved. always expecting that `f` returns a
promise that will be automatically unwrapped.

This is just a stricter version of `then` with reversed arguments in
the same way as `map`.

This is designed to be used with `->>`.
raw docstring

pending?clj/s

(pending? p)

Returns true if promise p is stil pending.

Returns true if promise `p` is stil pending.
raw docstring

pletclj/smacro

(plet bindings & body)

A parallel let; executes all the bindings in parallel and when all bindings are resolved, executes the body.

A parallel let; executes all the bindings in parallel and
when all bindings are resolved, executes the body.
raw docstring

promiseclj/s

(promise v)
(promise v executor)

The coerce based promise constructor. Creates a appropriate promise instance depending on the provided value.

If an executor is provided, it will be used to resolve this promise.

The coerce based promise constructor. Creates a appropriate promise
instance depending on the provided value.

If an executor is provided, it will be used to resolve this
promise.
raw docstring

promise?clj/s

(promise? v)

Return true if v is a promise instance.

Return true if `v` is a promise instance.
raw docstring

promisifyclj/s

(promisify callable)

Given a function that accepts a callback as the last argument return other function that returns a promise. Callback is expected to take single parameter (result of a computation).

Given a function that accepts a callback as the last argument return other
function that returns a promise. Callback is expected to take single
parameter (result of a computation).
raw docstring

raceclj/s

(race promises)

recurclj/smacro

(recur & args)

reject!clj/s

(reject! p e)

Reject a completable promise with an error.

Reject a completable promise with an error.
raw docstring

rejectedclj/s

(rejected v)

Return a rejected promise with provided reason.

Return a rejected promise with provided reason.
raw docstring

rejected?clj/s

(rejected? p)

Returns true if promise p is already rejected.

Returns true if promise `p` is already rejected.
raw docstring

resolve!clj/s

(resolve! o)
(resolve! o v)

Resolve a completable promise with a value.

Resolve a completable promise with a value.
raw docstring

resolvedclj/s

(resolved v)

Return a resolved promise with provided value.

Return a resolved promise with provided value.
raw docstring

resolved?clj/s

(resolved? p)

Returns true if promise p is already fulfilled.

Returns true if promise `p` is already fulfilled.
raw docstring

run!clj/s

(run! f coll)
(run! f coll executor)

A promise aware run! function.

A promise aware run! function.
raw docstring

thenclj/s

(then p f)
(then p f executor)

Chains a computation f (function) to be executed when the promise p is successfully resolved.

The computation will be executed in the calling thread by default; you also can provide a custom executor.

If the function f returns a promise instance, it will be automatically unwrapped.

Chains a computation `f` (function) to be executed when the promise
`p` is successfully resolved.

The computation will be executed in the calling thread by default;
you also can provide a custom executor.

If the function `f` returns a promise instance, it will be
automatically unwrapped.
raw docstring

then'clj/s

(then' p f)
(then' p f executor)

Chains a computation f (function) to be executed when the promise p is successfully resolved.

The computation will be executed in the calling thread by default; you also can provide a custom executor.

Don't perform flatten on the result.

Chains a computation `f` (function) to be executed when the promise
`p` is successfully resolved.

The computation will be executed in the calling thread by default;
you also can provide a custom executor.

Don't perform flatten on the result.
raw docstring

thenable?cljs

(thenable? v)

Returns true if v is a promise like object.

Returns true if `v` is a promise like object.
raw docstring

timeoutclj/s

(timeout p t)
(timeout p t v)
(timeout p t v scheduler)

Returns a cancellable promise that will be fulfilled with this promise's fulfillment value or rejection reason. However, if this promise is not fulfilled or rejected within ms milliseconds, the returned promise is cancelled with a TimeoutError

Returns a cancellable promise that will be fulfilled with this
promise's fulfillment value or rejection reason.  However, if this
promise is not fulfilled or rejected within `ms` milliseconds, the
returned promise is cancelled with a TimeoutError
raw docstring

TimeoutExceptioncljs

(TimeoutException message)

wrapclj/s

(wrap v)

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close