This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-06-08
Channels
- # babashka (9)
- # beginners (43)
- # biff (4)
- # calva (11)
- # cider (6)
- # clerk (1)
- # clj-kondo (4)
- # cljs-dev (6)
- # clojure (82)
- # clojure-berlin (1)
- # clojure-europe (42)
- # clojure-nl (1)
- # clojure-norway (182)
- # clojure-quebec (1)
- # clojure-uk (19)
- # clojurescript (6)
- # datahike (1)
- # emacs (30)
- # fulcro (5)
- # honeysql (6)
- # hyperfiddle (12)
- # lambdaisland (8)
- # malli (11)
- # off-topic (36)
- # pathom (26)
- # pedestal (1)
- # portal (25)
- # practicalli (1)
- # rdf (29)
- # re-frame (17)
- # reitit (1)
- # releases (1)
- # sci (37)
- # shadow-cljs (15)
- # vim (10)
- # xtdb (13)
How to convert this anonymous function to clojurescript?
logseq.App.onMacroRendererSlotted(async ({ slot, payload: { arguments: args, uuid } }) => {console.log(args)})
I don't know what to do with the async part nor the object argument part.
Here's what I got:
(js/logseq.App.onMacroRendererSlotted (fn [{slot, payload: {arguments: args, uuid}}] (println args))
The destructuring syntax is wrong and the function is async so you'll be dealing with a promise somewhere inside the function. Without additional context that's all that can be said
Here's how I'd write a 1-to-1 translation:
(-> js/logseq .-App
(.onMacroRendererSlotted
(fn [^js params]
(let [slot (.-slot params)
payload (.-payload params)
args (.-arguments payload)
uuid (.-uuid payload)]
(js/Promise.resolve (js/console.log args))))))
But I would also expect for Logseq to have a CLJS API.This seems relevant: https://github.com/logseq/logseq/blob/c45f066cf90fc5a39a6d0ed15107e440e51cd0ba/src/main/frontend/components/block.cljs#L1517
✅ 2
Thanks I'll check that out