https://github.com/active-group/cljs-async
A ClojureScript library for asynchronous programming
https://github.com/active-group/cljs-async
Last synced: 2 months ago
JSON representation
A ClojureScript library for asynchronous programming
- Host: GitHub
- URL: https://github.com/active-group/cljs-async
- Owner: active-group
- License: epl-1.0
- Created: 2020-11-23T16:59:32.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-12-02T17:53:49.000Z (over 5 years ago)
- Last Synced: 2025-12-12T21:57:26.284Z (6 months ago)
- Language: Clojure
- Size: 23.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
cljs-async
======
This is a library for asynchronous programming in ClojureScript based
on native JavaScript promises.
Besides basic functions to create and work with promises, which
correspond to the standardised [JavaScript Promise
API](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise),
this library contains an `async` macro that resembles async functions
in JavaScript, and functions that simplify writing asynchronous tests
with [`cljs.test`](https://cljs.github.io/api/cljs.test/).
The library is released on
[](https://clojars.org/de.active-group/cljs-async).
The generated API docs are available on
[cljdoc](https://cljdoc.xyz/d/de.active-group/cljs-async/CURRENT).
## Usage
Primitive promises can be created with `promise`:
```clojure
(core/promise
(fn [resolve reject]
...some asynchronous operation...
(resolve :result)))
```
To compose promises, the `async` macro is the most comfortable:
```clojure
(core/async
(let [v (core/await some-promise)
w (core/await some-other-promise)]
(* v w)))
```
## License
Copyright © 2020 Active Group GmbH
Distributed under the Eclipse Public License either version 1.0 or (at
your option) any later version.