Liking cljdoc? Tell your friends :D

com.wsscode.async.async-cljs


<!clj/smacro

(<! & body)

Same as clojure.core.async/<!!. Just a convenience place for it.

Same as clojure.core.async/<!!. Just a convenience place for it.
sourceraw docstring

<!maybeclj/smacro

(<!maybe x)

Reads a channel if it is a channel, if it's not a channel, return x.

Reads a channel if it is a channel, if it's not a channel, return x.
sourceraw docstring

<!pclj/smacro

(<!p promise)

Similar to core.async <!, but instead of taking a channel, <!p takes a Javascript Promise, converts to a channel and reads, this allows the use of regular JS promises inside go blocks using await like syntax.

Example:

(go ; start with go block
  (-> (js/fetch "some-url") <!p ; call fetch and await for response
      .text <!p ; await for text body reading
      js/console.log))
Similar to core.async <!, but instead of taking a channel, <!p takes a Javascript
Promise, converts to a channel and reads, this allows the use of regular JS promises
inside go blocks using await like syntax.

Example:

    (go ; start with go block
      (-> (js/fetch "some-url") <!p ; call fetch and await for response
          .text <!p ; await for text body reading
          js/console.log))
sourceraw docstring

<?clj/smacro

(<? ch)

Reads a channel value and check if it is an error, in case it is, throw the error.

Reads a channel value and check if it is an error, in case it is, throw the error.
sourceraw docstring

<?maybeclj/smacro

(<?maybe x)

Tries to await for a value, first if checks if x is a channel, if so will read on it; then it checks if it's a JS promise, if so will convert it to a channel and read from it. Otherwise returns x as is.

Tries to await for a value, first if checks if x is a channel, if so will read
on it; then it checks if it's a JS promise, if so will convert it to a channel
and read from it. Otherwise returns x as is.
sourceraw docstring

chan?cljs

(chan? c)

Check if c is a core.async channel.

Check if c is a core.async channel.
sourceraw docstring

consumer-paircljs

(consumer-pair resp)

Consume promise channel result pair.

Consume promise channel result pair.
sourceraw docstring

deftest-asyncclj/smacro

(deftest-async sym & body)

Define an async test, this helper uses the cljs.test async feature, the user body will be wrapped around a go block automatically and the async done will be called after the go block finishes it's execution. Example:

(wa/deftest-async async-test
  (is (= 42 (<! (some-async-op))))

This will also add a timeout (default 2000ms), to change the timeout you can send a map with configuration after the test symbol, example:

(wa/deftest-async async-test
  {::wa/timeout 5000} ; 5000ms timeout
  (is (= 42 (<! (some-async-op))))
Define an async test, this helper uses the cljs.test async feature, the user body
will be wrapped around a `go` block automatically and the async done will be called
after the go block finishes it's execution. Example:

    (wa/deftest-async async-test
      (is (= 42 (<! (some-async-op))))

This will also add a timeout (default 2000ms), to change the timeout you can send
a map with configuration after the test symbol, example:

    (wa/deftest-async async-test
      {::wa/timeout 5000} ; 5000ms timeout
      (is (= 42 (<! (some-async-op))))
sourceraw docstring

error?cljs

(error? err)

Returns true if err is an error object.

Returns true if err is an error object.
sourceraw docstring

goclj/smacro

(go & body)

Same as cljs.core.async/go. Just a convenience place for it.

Same as cljs.core.async/go. Just a convenience place for it.
sourceraw docstring

go-catchclj/smacro

(go-catch & body)

Creates a go block that has a try/catch wrapping body, in case of errors the error flows up as data instead triggering the exception.

Creates a go block that has a try/catch wrapping body, in case of errors the error
flows up as data instead triggering the exception.
sourceraw docstring

go-promiseclj/smacro

(go-promise & body)

Creates a go block using a promise channel, so the output of the go block can be read any number of times once ready.

Creates a go block using a promise channel, so the output of the go block can be
read any number of times once ready.
sourceraw docstring

let-chanclj/smacro

(let-chan [name value] & body)

Handles a possible channel on value.

Handles a possible channel on value.
sourceraw docstring

let-chan*clj/smacro

(let-chan* [name value] & body)

Like let-chan, but async errors will be returned instead of propagated

Like let-chan, but async errors will be returned instead of propagated
sourceraw docstring

promise->chancljs

(promise->chan p)

Converts promise p in a promise-chan. The response of this channel should be consumed using consume-pair.

Converts promise p in a promise-chan. The response of this channel should be consumed
using `consume-pair`.
sourceraw docstring

promise?cljs

(promise? x)

Return true if X is a js obj with the property .then available as a fn.

Return true if X is a js obj with the property .then available as a fn.
sourceraw docstring

throw-errcljs

(throw-err x)

Throw error x if x is an error.

Throw error x if x is an error.
sourceraw docstring

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

× close