This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-03-29
Channels
- # announcements (1)
- # biff (5)
- # calva (10)
- # cljdoc (4)
- # clojure (17)
- # clojure-europe (15)
- # clojure-norway (38)
- # clojurescript (53)
- # community-development (1)
- # cursive (2)
- # datomic (14)
- # fulcro (11)
- # funcool (1)
- # hyperfiddle (7)
- # introduce-yourself (2)
- # jobs-discuss (17)
- # missionary (7)
- # releases (4)
- # shadow-cljs (30)
- # slack-help (6)
- # specter (5)
- # squint (22)
this input is supposed to add a new item, then clear itself on blur.
(ns test.test
(:require [hyperfiddle.electric :as e]
[hyperfiddle.electric-ui4 :as ui]
[hyperfiddle.electric-dom2 :as dom :refer [div text props on]]))
#?(:clj (def !items (atom ["a" "b" "c"])))
(e/defn Test []
(e/client
(div (text (pr-str (e/server (e/watch !items)))))
(let [!v (atom "")
*v (e/watch !v)]
;; new item ui
(ui/input
*v
(e/fn [s] (reset! !v s))
(on "blur"
(when-not (empty? *v)
(e/fn [e]
(e/server (swap! !items conj *v)) ;; add new item
(reset! !v "") ;; clear the input for the next new item
)))))))
why do i get this error?
#error {:message called `new` on nil, :data {}}
when I comment out the (reset! v! "")
on the last line, i don't get the error anymore.If *v
is blank, you are registering nil
as the blur handler. I think you probably want to check for blank inside your blur handler efn
🙏 1
Has any one got flow storm debugger working with electric?
oh I might be hitting this https://clojurians.slack.com/archives/C03KZ3XT0CF/p1711736387725389