This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-01-28
Channels
- # asami (5)
- # babashka (44)
- # beginners (22)
- # biff (7)
- # clerk (86)
- # clj-kondo (5)
- # clojure (33)
- # clojure-europe (8)
- # clr (6)
- # community-development (2)
- # fulcro (20)
- # graalvm (5)
- # graphql (1)
- # hugsql (3)
- # integrant (5)
- # java (11)
- # joyride (2)
- # leiningen (4)
- # malli (12)
- # nbb (15)
- # off-topic (28)
- # pathom (23)
- # reitit (8)
- # releases (1)
- # sci (6)
- # shadow-cljs (39)
- # tools-deps (15)
- # tree-sitter (1)
I'm trying to write a hook for a macro that acts a lot like try
/ catch
, but instead uses async
& fallback
. here's my first pass:
(defn async
[{:keys [node]}]
(let [body (:children node)
fallback (last body)
body (rest (drop-last body))]
(if (= 'fallback (first (api/sexpr fallback)))
(doto (with-meta
(api/list-node
`(try
~@body
~(api/list-node
`(catch js/Promise p#
~@(rest (:children fallback))))))
(meta node))
prn)
(throw (ex-info "Last expr in async must be fallback" {:node node})))))
however, using it like
(async "foo" "bar" (fallback "loading ..."))
still emits an error src/town/lilac/dom.cljs:231:8: error: Unresolved symbol: fallback