This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-12-15
Channels
- # adventofcode (46)
- # announcements (3)
- # aws (7)
- # babashka (47)
- # beginners (86)
- # calva (40)
- # cider (8)
- # clj-kondo (22)
- # clojure (63)
- # clojure-europe (16)
- # clojure-hungary (3)
- # clojure-nl (1)
- # clojure-norway (46)
- # clojure-sweden (1)
- # clojure-uk (3)
- # clojuredesign-podcast (2)
- # conjure (4)
- # datalevin (1)
- # events (1)
- # fulcro (5)
- # graalvm (4)
- # honeysql (8)
- # hyperfiddle (15)
- # music (1)
- # off-topic (5)
- # pathom (7)
- # pedestal (1)
- # polylith (3)
- # portal (19)
- # quil (1)
- # re-frame (36)
- # releases (1)
- # specter (3)
- # sql (3)
- # timbre (11)
- # tools-deps (4)
- # xtdb (55)
Ive got a spinner. The entry point for it looks like this:
(e/defn MountSpinnerAs
[id]
(e/client
(let [set-loading-state! (second loading-state)]
(ops/when-repl (timbre/info "Mounting spinner for" id))
(set-loading-state! #(conj % id))
(e/on-unmount (fn []
(js/setTimeout
(fn []
(ops/when-repl (timbre/info "Unmounting spinner for" id))
(set-loading-state! #(disj % id)))
60))))))
I’m calling it here:
(e/defn BindAccount
[Next]
(e/server
(let [{:keys [logout-url]
:user/keys [account]
:as user-info}
(try (session/Authenticate.)
(catch Pending _ nil))]
(if-not account
(MountSpinnerAs. :BindAccount)
This generates the following error:
TypeError: Cannot set properties of undefined (setting '3')
at Object.hyperfiddle$electric$impl$runtime$input_change [as input_change] (runtime.cljc:373:15)
at hyperfiddle$electric$impl$runtime$eval_change_inst (runtime.cljc:819:6)
at eval (core.cljs:7387:25)
at Object.cljs$core$inode_kv_reduce [as inode_kv_reduce] (core.cljs:7391:28)
at Object.eval [as kv_reduce] (core.cljs:7633:6)
at Object.eval [as cljs$core$IKVReduce$_kv_reduce$arity$3] (core.cljs:8197:50)
at Object.cljs$core$_kv_reduce [as _kv_reduce] (core.cljs:719:16)
at Object.cljs$core$reduce_kv [as reduce_kv] (core.cljs:2628:8)
at hyperfiddle$electric$impl$runtime$parse_event (runtime.cljc:836:11)
at eval (core.cljs:5750:36)
This is fixed by adding e/client
:
(e/defn BindAccount
[Next]
(e/server
(let [{:keys [logout-url]
:user/keys [account]
:as user-info}
(try (session/Authenticate.)
(catch Pending _ nil))]
(if-not account
(e/client (MountSpinnerAs. :BindAccount)) ;; <--
Why? (This is IC)To follow up – we have no idea, if you're up for reducing to a minimal repro we will prioritize it
I tried migrating to IC last night and noticed a bunch of code now requiring e/client that didn’t before. Ultimately didn’t manage to port my code and going to revisit it later. Seems like IC requires being more explicit.
It does require more coloring, specifically at the top-level of each function (as you can see above). I see it as kind of an improvement, as you don’t have to browse around to understand which context the code is executing in. So we kind of had this down as a practice before IC.
Yea I also agree that it is good to have this. I also have some hacks it is not happy with which is just a nice time to refactor.
Yeah, IC seems a bit more temperamental in some cases. There are specifically two places in our code where the error, and the solution, makes no sense to me. I found the solutions just by blindly trying things.
Having the option to not specify would be nice. For some functions the context is very obvious
If you want code that runs on client or server depending on where you insert it, you can always write a macro.
coloring is only required when platform specific forms are used, like (js/console.log …). Otherwise the form will be compiled for both sites. If it is not the case please report a bug
With my code I wasn’t coloring a component when it was used in a parent component e/client form.