Skip to content

Commit a1dd8d0

Browse files
committed
Add helper for launching portal
1 parent 37e3852 commit a1dd8d0

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

dev/user.clj

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
(ns user)
2+
3+
(defmacro jit [sym]
4+
`(requiring-resolve '~sym))
5+
6+
(def portal-instance (atom nil))
7+
8+
(defn portal
9+
"Open a Portal window and register a tap handler for it. The result can be
10+
treated like an atom."
11+
[]
12+
;; Portal is both an IPersistentMap and an IDeref, which confuses pprint.
13+
(prefer-method @(jit clojure.pprint/simple-dispatch) clojure.lang.IPersistentMap clojure.lang.IDeref)
14+
(let [p ((jit portal.api/open) @portal-instance)]
15+
(reset! portal-instance p)
16+
(add-tap (jit portal.api/submit))
17+
p))

0 commit comments

Comments
 (0)