This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-11-30
Channels
- # adventofcode (3)
- # announcements (4)
- # babashka (42)
- # beginners (56)
- # biff (23)
- # cider (8)
- # clj-yaml (2)
- # cljdoc (16)
- # clojure (83)
- # clojure-europe (52)
- # clojure-nl (3)
- # clojure-norway (4)
- # clojure-sweden (2)
- # clojure-uk (2)
- # clojurebridge (1)
- # clojurescript (2)
- # cloverage (1)
- # cursive (11)
- # data-oriented-programming (1)
- # deps-new (2)
- # dev-tooling (2)
- # emacs (3)
- # etaoin (4)
- # events (5)
- # fulcro (5)
- # gratitude (3)
- # java (3)
- # jobs (1)
- # jobs-discuss (1)
- # joyride (33)
- # malli (16)
- # music (1)
- # nbb (1)
- # nrepl (4)
- # nyc (1)
- # off-topic (25)
- # pathom (8)
- # re-frame (1)
- # reitit (7)
- # remote-jobs (2)
- # shadow-cljs (6)
- # tools-deps (9)
Hi all, I’m using rum+datascript in a frontend application with core.async as an event bus (like @tonsky’s cat chat demo) which is awesome but I’m having some issues with the entire component tree being re-rendered on each change to the db (it causes inputs to be re-created when they are children, this leads to them losing focus while the user types). Has anyone come up with a nice solution so that components in the tree can subscribe to only update when certain entities/queries change? Similar to using an atom and cursor basically but with datascript.
For some extra info I’ve been working on a mixin like this but don’t quite have it yet:
(defn react-on [attr]
{:did-mount (fn [state]
(d/listen! conn (fn [tx-report]
(when (some #(= (nth % 1) attr) (:tx-data tx-report))
(println (str "attribute " attr " changed"))
(rum/request-render (:rum/react-component state))))))})
The idea being to define a component and dependent attribute (or query - to be implemented later) like this:
(rum/defc my-component < (react-on :some/attr) [])