hyperfiddle

Absolute Negativity 2025-05-25T05:06:05.625119Z

Not sure what's wrong, anyone seeing this? Hi, I think there's a bug in the latest snapshot...

Absolute Negativity 2025-05-25T13:20:54.359109Z

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)))))

Absolute Negativity 2025-05-26T04:32:29.832679Z

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)))

xificurC 2025-05-28T14:44:02.767679Z

I can repro this. Definitely a bug. We'll keep you posted

🙏 1
xificurC 2025-06-11T09:55:50.258219Z

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

Absolute Negativity 2025-06-11T10:14:05.269899Z

Okay. I appreciate all you guys works!

Absolute Negativity 2025-05-25T05:06:40.055639Z

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-request

Absolute Negativity 2025-05-25T05:10:51.238739Z

xificurC 2025-05-26T11:25:59.698379Z

Thanks 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?

1
Absolute Negativity 2025-05-26T12:25:37.514109Z

Thank you! Yah. Same date as one on Clojars. Deleted ~/.m2 cache and tested the snippet on fresh starter app project.