Liking cljdoc? Tell your friends :D

district0x/async-helpers

Build Status

Clojurescript library with functions aiding in handling asynchronous events. This library currently utilises timbre as a logging library. You shoud use it in conjunction with the district-server-logging and district-ui-logging modules which setup various logging appenders.

Installation

Add into your project.clj:
Clojars Project

Include [district.shared.async-helpers] in your CLJS file.

district.shared.async-helpers

promise->

  • Takes a JS Promise as a first argument and a sequence of function calls to be chained. Takes care of error handling.

Example:

(promise-> (js/Promise.resolve :one)
           #(prn "RESOLVED %)
           #(js/Promise.resolve :two)
           #(prn "RESOLVED %))

For rationale and more use-cases see this blog post.

promise->chan

  • Takes a JS Promise as its argument and returns a core.async channel with the value it resolves to.

promise?

  • Predicate function, returns true if its argument is an instance of a JS Promise.

defer

  • Macro which takes a body and executes it in the next iteration of the nodejs Event Loop.

Library dependencies

district-server-logging

error-handling requires a configured district-server-logging and/or district-ui-logging modules to function correctly. Depending on where the code is run and how the logging is configured your errors will be reported to the browser, node.js console, log file, sentry etc.

For possible configuration options please see district-server-logging and district-ui-logging.

Can you improve this documentation?Edit on GitHub

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

× close