File tree 3 files changed +22
-8
lines changed
3 files changed +22
-8
lines changed Original file line number Diff line number Diff line change 1
- # core.async-helpers [ ![ Clojars Project] ( https://img.shields.io/clojars/v/jtk-dvlp/core.async-helpers.svg )] ( https://clojars.org/jtk-dvlp/core.async-helpers ) [ ![ cljdoc badge] ( https://cljdoc.org/badge/jtk-dvlp/core.async-helpers )] ( https://cljdoc.org/d/jtk-dvlp/core.async-helpers/CURRENT )
1
+ [ ![ Clojars Project] ( https://img.shields.io/clojars/v/jtk-dvlp/core.async-helpers.svg )] ( https://clojars.org/jtk-dvlp/core.async-helpers )
2
+ [ ![ cljdoc badge] ( https://cljdoc.org/badge/jtk-dvlp/core.async-helpers )] ( https://cljdoc.org/d/jtk-dvlp/core.async-helpers/CURRENT )
3
+ [ ![ License] ( https://img.shields.io/badge/License-EPL%202.0-red.svg )] ( https://opensource.org/licenses/EPL-2.0 )
4
+
5
+ # core.async-helpers
2
6
3
7
Helper pack for core.async
Original file line number Diff line number Diff line change 4
4
5
5
#? (:cljs
6
6
(:require-macros
7
- [jtk-dvlp.async :refer [go* <e! safe ]]))
7
+ [jtk-dvlp.async :refer [go* <e! <p! ]]))
8
8
9
9
#? (:clj
10
10
(:require
11
11
[clojure.core.async :as async]
12
- [jtk-dvlp.async.interop.promise :as p])
12
+ [jtk-dvlp.async.interop.promise]
13
13
14
14
:cljs
15
15
(:require
16
16
[clojure.core.async :as async]
17
- [jtk-dvlp.async.interop.promise :as p ])))
17
+ [jtk-dvlp.async.interop.promise])))
18
18
19
19
20
20
#? (:clj
76
76
chs))
77
77
78
78
(defn promise-chan
79
- " TODO"
79
+ " Creates an promise like channel, see `core.async/promise-chan`.
80
+
81
+ Given function `f` can be used to fill the promise.
82
+ `f` will be called with one arg functions `resolve` and `reject`
83
+ to resolve or reject the created promise. Rejection value will
84
+ will be used as `ex-info` `cause`."
80
85
([]
81
86
(async/promise-chan ))
82
87
95
100
c)))
96
101
97
102
(defn ->promise-chan
103
+ " Ensure given channel `c` to be a `promise-chan` via
104
+ `pipe` it into a new `promise-chan`. See `core.async/promise-chan`
105
+ for more infos."
98
106
[c]
99
107
(->> (async/promise-chan )
100
108
(async/pipe c)))
101
109
102
110
#? (:clj
103
111
(defmacro <p!
104
- " Like `<!` for a promise via `p->c`."
112
+ " Like `<e!` for promise via `p->c` convertion.
113
+
114
+ Usage in combination with `go*`."
105
115
[?exp]
106
- `(<e! (p /p->c ~?exp))))
116
+ `(<e! (jtk-dvlp.async.interop.promise /p->c ~?exp))))
Original file line number Diff line number Diff line change 13
13
14
14
15
15
(defn p->c
16
- " Creates a promise-channel and put the val of resolved promise `p`
16
+ " Creates a ` promise-chan` and put the val of resolved promise `p`
17
17
or put an instance of `ExceptionInfo` if promise is rejected.
18
18
Closes the channel after took val."
19
19
[p]
You can’t perform that action at this time.
0 commit comments