Liking cljdoc? Tell your friends :D

promesa.core


aletcljmacro

(alet bindings & body)

A let alternative that always returns promise and allows use await marker function in order to emulate the async/await syntax and make the let expression look like synchronous where async operations are performed.

A `let` alternative that always returns promise and allows
use `await` marker function in order to emulate the async/await
syntax and make the let expression look like synchronous where
async operations are performed.
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

attemptclj/s

(attempt callback)

A helper for start promise chain without worry about synchronous or asynchronous exceptions. Returns a promise resolved with the return value of the callback.

A helper for start promise chain without worry about
synchronous or asynchronous exceptions. Returns a promise
resolved with the return value of the callback.
raw docstring

awaitclj/s

(await & args)

bindclj/s

(bind p f)

A chain helper for promises.

A chain helper for promises.
raw docstring

branchclj/s

(branch p success failure)

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)

Catch all promise chain helper.

Catch all promise chain helper.
raw docstring

chainclj/s

(chain p & funcs)

Like then but accepts multiple parameters.

Like then but accepts multiple parameters.
raw docstring

delayclj/s

(delay t)
(delay t v)

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*cljmacro

(do* & body)

A sugar syntax on top of attempt.

A sugar syntax on top of `attempt`.
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

extend-promise!cljs

(extend-promise! promise)

A helper function that attaches the internal protocols implementation to a specified type. Usefull if you want to use different promise implementations with promesa functions.

A helper function that attaches the internal protocols implementation
to a specified type. Usefull if you want to use different promise
implementations with promesa functions.
raw docstring

extractclj/s

(extract p)

Returns the current promise value.

Returns the current promise value.
raw docstring

finallyclj/s

(finally p callback)

Attach handler to promise that will be executed independently if promise is resolved or rejected.

Attach handler to promise that will be
executed independently if promise is
resolved or rejected.
raw docstring

mapclj/s

(map f p)

Apply a function to the promise value and return a new promise with the result.

Apply a function to the promise value and
return a new promise with the result.
raw docstring

mapcatclj/s

(mapcat f p)

Same as map but removes one level of promise neesting. Useful when the map function returns a promise instead of value.

In JS environment this function is analogous to map because the promise abstraction overloads the map operator.

Same as `map` but removes one level of
promise neesting. Useful when the map function
returns a promise instead of value.

In JS environment this function is analogous
to `map` because the promise abstraction overloads
the `map` operator.
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

promiseclj/s

(promise)
(promise v)

The promise constructor.

The promise constructor.
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)

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! p 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

scheduleclj/s

(schedule ms func)

Schedule a callable to be executed after the ms delay is reached.

In JVM it uses a scheduled executor service and in JS it uses the setTimeout function.

Schedule a callable to be executed after the `ms` delay
is reached.

In JVM it uses a scheduled executor service and in JS
it uses the `setTimeout` function.
raw docstring

set-default-promise!cljs

(set-default-promise! promise)

Sets the default promise type that should be used for creating all promise instances.

Sets the default promise type that should be used for creating
all promise instances.
raw docstring

set-executor!clj

(set-executor! executor)

Replace the default executor instance with your own instance.

Replace the default executor instance with
your own instance.
raw docstring

thenclj/s

(then p f)

Similar to map but with parameters inverted for convenience and for familiarity with javascript's promises .then operator.

Unlike Clojure's map, will resolve any promises returned by f.

Similar to `map` but with parameters inverted
for convenience and for familiarity with
javascript's promises `.then` operator.

Unlike Clojure's `map`, will resolve any promises
returned  by `f`.
raw docstring

timeoutclj/s

(timeout p t)
(timeout p t v)

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)

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

× close