Skip to content

Commit 4c4be37

Browse files
committed
Adds some hint to the readme and simplifies example code
1 parent 769949b commit 4c4be37

File tree

2 files changed

+41
-42
lines changed

2 files changed

+41
-42
lines changed

README.md

+24-21
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ Add the following dependency to your `project.clj`:<br>
2424

2525
### Usage
2626

27+
Pay attention mixing up error propagation functions of this library and clojure.core.async functions. clojure.core.async function do not propagate errors. E.g. using a core.async go-block within a error propagation go-block stack will break error propagation. So do not mix it up!
28+
2729
```clojure
2830
(ns your-project
2931
#?(:clj
@@ -34,10 +36,16 @@ Add the following dependency to your `project.clj`:<br>
3436
:cljs
3537
(:require
3638
[cljs.core.async :refer [timeout]]
37-
[jtk-dvlp.async :as a])))
39+
[jtk-dvlp.async :as a]))
40+
41+
#?(:clj
42+
(:import
43+
[clojure.lang ExceptionInfo]))
3844

45+
,,,)
3946

40-
(defn ?do-some-async-stuff
47+
48+
(defn <do-some-async-stuff
4149
[& args]
4250
(a/go
4351
(a/<! (timeout 1000))
@@ -47,37 +55,32 @@ Add the following dependency to your `project.clj`:<br>
4755
(println result)
4856
result)))
4957

50-
(defn ?fail-during-some-async-stuff
58+
(defn <fail-during-some-async-stuff
5159
[& args]
5260
(a/go
5361
(a/<! (timeout 1000))
5462
(->> {:call-args args}
5563
(ex-info "you got a bug")
5664
(throw))))
5765

58-
(defn ?do-some-more-stuff
59-
[]
66+
(comment
6067
(a/go
61-
(let [a
62-
(a/<! (?do-some-async-stuff :a))
68+
(try
69+
(let [a
70+
(a/<! (<do-some-async-stuff :a))
6371

64-
b
65-
(a/<! (?fail-during-some-async-stuff :b))
72+
b
73+
(a/<! (<fail-during-some-async-stuff :b))
6674

67-
c
68-
(a/<! (?do-some-async-stuff :c))]
75+
c
76+
(a/<! (<do-some-async-stuff :c))]
6977

70-
[a b c])))
78+
(println [a b c]))
7179

72-
(comment
73-
(a/go
74-
(try
75-
(->> (?do-some-more-stuff)
76-
(a/<!)
77-
(println "success"))
78-
(catch #?(:clj Throwable
79-
:cljs :default) e
80-
(println "there is an error" e)))))
80+
(catch ExceptionInfo e
81+
(println "there is an error" e))))
82+
83+
,,,)
8184
```
8285

8386

dev/your_project.cljc

+17-21
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@
1212
#?(:clj
1313
(:import
1414
[clojure.lang ExceptionInfo]))
15-
)
1615

16+
,,,)
1717

18-
(defn ?do-some-async-stuff
18+
19+
(defn <do-some-async-stuff
1920
[& args]
2021
(a/go
2122
(a/<! (timeout 1000))
@@ -25,34 +26,29 @@
2526
(println result)
2627
result)))
2728

28-
(defn ?fail-during-some-async-stuff
29+
(defn <fail-during-some-async-stuff
2930
[& args]
3031
(a/go
3132
(a/<! (timeout 1000))
3233
(->> {:call-args args}
3334
(ex-info "you got a bug")
3435
(throw))))
3536

36-
(defn ?do-some-more-stuff
37-
[]
37+
(comment
3838
(a/go
39-
(let [a
40-
(a/<! (?do-some-async-stuff :a))
39+
(try
40+
(let [a
41+
(a/<! (<do-some-async-stuff :a))
4142

42-
b
43-
(a/<! (?fail-during-some-async-stuff :b))
43+
b
44+
(a/<! (<fail-during-some-async-stuff :b))
4445

45-
c
46-
(a/<! (?do-some-async-stuff :c))]
46+
c
47+
(a/<! (<do-some-async-stuff :c))]
4748

48-
[a b c])))
49+
(println [a b c]))
4950

50-
(comment
51-
(a/go
52-
(try
53-
(->> (?do-some-more-stuff)
54-
(a/<!)
55-
(println "success"))
56-
(catch #?(:clj ExceptionInfo
57-
:cljs :default) e
58-
(println "there is an error" e)))))
51+
(catch ExceptionInfo e
52+
(println "there is an error" e))))
53+
54+
,,,)

0 commit comments

Comments
 (0)