Liking cljdoc? Tell your friends :D

redlobster.macros


defercljmacro

(defer & forms)

Run the given forms in the next tick of the event loop, or if the first argument is a number, run the following forms after the given number of milliseconds have elapsed.

Run the given forms in the next tick of the event loop, or if the
first argument is a number, run the following forms after the given
number of milliseconds have elapsed.
sourceraw docstring

defer-nodecljmacro

(defer-node form)
(defer-node form transformer)

Appends a callback to a given form which takes two arguments [error value] and executes it, returning a promise that will fail with error if error is truthy, and realise with value if error is falsy. This is a common Node callback idiom, so this macro can be useful for wrapping Node calls in promises, eg.:

(defer-node (.readFile fs "/etc/passwd"))

The above code will call fs.readFile() and return a promise that will realise with the file's contents when the operation is done, or fail with an appropriate error if the operation returns one.

Optionally, you can specify a transformer function to apply to the success value before it's realised. js->clj is a likely candidate.

Appends a callback to a given form which takes two arguments `[error value]`
and executes it, returning a promise that will fail with `error` if `error`
is truthy, and realise with `value` if `error` is falsy. This is a common
Node callback idiom, so this macro can be useful for wrapping Node calls in
promises, eg.:

    (defer-node (.readFile fs "/etc/passwd"))

The above code will call fs.readFile() and return a promise that will realise
with the file's contents when the operation is done, or fail with an appropriate
error if the operation returns one.

Optionally, you can specify a transformer function to apply to the success value
before it's realised. `js->clj` is a likely candidate.
sourceraw docstring

if-let-realisedcljmacro

(if-let-realised [binding value] success fail)
source

let-coll-realisedcljmacro

(let-coll-realised [binding collection] & forms)

Like let-realised, except that it takes a single binding that returns a collection and waits for its elements to realise.

Like `let-realised`, except that it takes a single binding that returns a
collection and waits for its elements to realise.
sourceraw docstring

let-realisedcljmacro

(let-realised bindings & forms)

Like when-realised, except it takes a binding form of variable/promise pairs instead of just a list of variables, and binds these to the macro scope.

Like `when-realised`, except it takes a binding form of variable/promise
pairs instead of just a list of variables, and binds these to the macro scope.
sourceraw docstring

promisecljmacro

(promise & forms)

Return a promise that will be realised by the given forms. The functions realise and realise-error will be available inside the macro body, and one of these should be called at some point within the forms to realise the promise.

Return a promise that will be realised by the given forms. The functions
`realise` and `realise-error` will be available inside the macro body, and one
of these should be called at some point within the forms to realise the promise.
sourceraw docstring

waitpcljmacro

(waitp join-promise success failure)

Creates a promise that waits for another promise to be realised, and calls the provided success or failure function respectively to realise the created promise. As with the promise macro, the functions realise and realise-error will be available inside the macro body and should be called to realise the promise.

Creates a promise that waits for another promise to be realised, and
calls the provided success or failure function respectively to realise the
created promise. As with the `promise` macro, the functions `realise` and
`realise-error` will be available inside the macro body and should be called
to realise the promise.
sourceraw docstring

when-realisedcljmacro

(when-realised promises & forms)

Given a sequence of promises, defer execution of the body until they have all been successfully realised. If one or more of the promises fail, do not execute anything. Return a promise that will realise with the result of evaluating the forms, or fail with the value of the first dependent promise to fail.

Given a sequence of promises, defer execution of the body until they have
all been successfully realised. If one or more of the promises fail, do not
execute anything. Return a promise that will realise with the result of
evaluating the forms, or fail with the value of the first dependent promise
to fail.
sourceraw docstring

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

× close