-
Notifications
You must be signed in to change notification settings - Fork 0
/
async.cljc
55 lines (40 loc) · 1.72 KB
/
async.cljc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
(ns mayu.async
#?(:clj (:require [net.cgrand.macrovich :as macros]
[clojure.core.async])
:cljs (:require [cljs.core.async]))
#?(:cljs (:require-macros [cljs.core.async]
[mayu.async :refer [go go-loop alt!]])))
#?(:clj
(defmacro go [& forms]
`(~(macros/case :clj 'clojure.core.async/go
:cljs 'cljs.core.async/go) ~@forms)))
#?(:clj
(defmacro go-loop [& forms]
`(~(macros/case :clj 'clojure.core.async/go-loop
:cljs 'cljs.core.async/go-loop) ~@forms)))
#?(:clj
(defmacro alt! [& forms]
`(~(macros/case :clj 'clojure.core.async/alt!
:cljs 'cljs.core.async/alt!) ~@forms)))
(def chan #?(:clj clojure.core.async/chan
:cljs cljs.core.async/chan))
(def put! #?(:clj clojure.core.async/put!
:cljs cljs.core.async/put!))
(def take! #?(:clj clojure.core.async/take!
:cljs cljs.core.async/take!))
(def >! #?(:clj clojure.core.async/>!
:cljs cljs.core.async/>!))
(def <! #?(:clj clojure.core.async/<!
:cljs cljs.core.async/<!))
(def buffer #?(:clj clojure.core.async/buffer
:cljs cljs.core.async/buffer))
(def dropping-buffer #?(:clj clojure.core.async/dropping-buffer
:cljs cljs.core.async/dropping-buffer))
(def sliding-buffer #?(:clj clojure.core.async/sliding-buffer
:cljs cljs.core.async/sliding-buffer))
(def timeout #?(:clj clojure.core.async/timeout
:cljs cljs.core.async/timeout))
(def close! #?(:clj clojure.core.async/close!
:cljs cljs.core.async/close!))
(def alts! #?(:clj clojure.core.async/alts!
:cljs cljs.core.async/alts!))