Not sure what's wrong, anyone seeing this? Hi, I think there's a bug in the latest snapshot...
this works
(comment
(reset! !k :a)
(reset! !k :b)
)
(defonce !k (atom nil))
(e/defn Foo []
(e/server
(let [k (e/watch !k)]
(dom/div (dom/text (case k :a "A" :b "B" "NONE"))))))
(e/defn Main [ring-request]
(e/client
(binding [dom/node js/document.body
e/http-request (e/server ring-request)]
(dom/div (Foo) (Foo)))))The original problem occurred in my project. Re-arranging case to execute on client like here seems to fix it:
(e/client
(case (e/server (::menu state/session))
::menu.some-page
(e/server (SomePage <some-server-state>))
::menu.some-other-page
(e/server (SomeOtherPage <some-server-state>))
(e/amb)))
I can repro this. Definitely a bug. We'll keep you posted
to keep you posted, this relates to an internal bug we're in the midst of fixing. No ETA yet, the change is in the internals and therefore requires careful planning and testing
Okay. I appreciate all you guys works!
In the following example, when I alternate !k between :a and :b, the dom divs keep building up instead of being unmounted by case. Am I'm missing something?
(ns electric-starter-app.main
(:require [hyperfiddle.electric3 :as e]
[hyperfiddle.electric-dom3 :as dom]
[electric-starter-app.two-clocks :refer [TwoClocks]]))
(comment
(reset! !k :a)
(reset! !k :b)
)
(defonce !k (atom nil))
(e/defn Foo []
(e/server
(case (e/watch !k)
:a (dom/div (dom/text "A"))
:b (dom/div (dom/text "B"))
(dom/div (dom/text "NONE")))))
(e/defn Main [ring-request]
(e/client
(binding [dom/node js/document.body
e/http-request (e/server ring-request)]
(dom/div
(e/server
(dom/div
(Foo) (Foo)))))))
(defn electric-boot [ring-request]
#?(:clj (e/boot-server {} Main (e/server ring-request)) ; inject server-only ring-request
:cljs (e/boot-client {} Main (e/server (e/amb))))) ; symmetric – same arity – no-value hole in place of server-only ring-requestThanks for the report. We're out at reclojure but we will take a look at this once we're back. Are you running on latest?
Thank you! Yah. Same date as one on Clojars. Deleted ~/.m2 cache and tested the snippet on fresh starter app project.