This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-03-02
Channels
- # announcements (9)
- # babashka (67)
- # beginners (62)
- # bitcoin (2)
- # clara (1)
- # clj-kondo (62)
- # cljfx (6)
- # cljs-dev (25)
- # clojars (17)
- # clojure (142)
- # clojure-australia (2)
- # clojure-europe (42)
- # clojure-gamedev (2)
- # clojure-nl (31)
- # clojure-poland (10)
- # clojure-spec (14)
- # clojure-uk (30)
- # clojurescript (3)
- # conjure (1)
- # cursive (10)
- # data-science (1)
- # datascript (4)
- # datomic (9)
- # depstar (7)
- # fulcro (17)
- # girouette (15)
- # graalvm (44)
- # honeysql (20)
- # jackdaw (3)
- # jobs (8)
- # jobs-discuss (10)
- # juxt (5)
- # lein-figwheel (1)
- # lsp (175)
- # malli (19)
- # pedestal (2)
- # reagent (31)
- # reitit (2)
- # remote-jobs (3)
- # reveal (12)
- # sci (77)
- # shadow-cljs (22)
- # specter (6)
- # startup-in-a-month (2)
- # tools-deps (1)
- # xtdb (21)
Hi, can I use an atom from another namespace, so when it changes there, my renderer updates? Can I make it trigger an event every time it changes or do I need to make my whole app be based on a subscription model?
In my example I hit a button which runs a function that maps a subfunction. I would like to update a progress bar every time this subfunction finishes.
I believe the general idea comes from the re-frame model where the whole app state is derived from a single "source of truth" (https://day8.github.io/re-frame/a-loop/), so the easiest way to accomplish that in that model is to have a (nested) map in the central state atom that coordinates those events/subscriptions. This model tends to work well for javafx as the visual rendering happens in a single thread anyways (just like javascript).
but it might be worth looking into https://github.com/vlaaad/reveal/blob/0ae45590a3792d05160ba0359e9c98691a43ec6d/src/vlaaad/reveal/fx.clj which mimics local mutable state with a *state
atom in the global state
@jasmin I'm not quite understanding your setup... I think it's better to have a single atom for the whole UI state. If your "logic" has multiple mutable references (e.g. multiple loaders that report progress), it's probably a good idea to add watchers to these refs that update value in UI state ref