This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-11-20
Channels
- # announcements (1)
- # babashka (4)
- # beginners (8)
- # cider (4)
- # clj-kondo (10)
- # cljdoc (1)
- # cljsrn (7)
- # clojure (3)
- # clojure-europe (20)
- # clojure-france (3)
- # clojure-sg (2)
- # clojurescript (16)
- # clojureverse-ops (3)
- # community-development (5)
- # core-async (35)
- # cursive (1)
- # datahike (14)
- # datomic (7)
- # events (5)
- # fulcro (59)
- # graphql (11)
- # lsp (33)
- # meander (1)
- # off-topic (33)
- # polylith (23)
- # portal (33)
- # re-frame (1)
- # reagent (10)
- # reclojure (7)
- # reveal (14)
is it better to have a single state
r/atom for a component that i make multiple cursors for, or multiple single-value r/atoms?
There is no right answer for this. I use re-frame, which has a single ratom that holds most state, and the app performs very well with just that one ratom. Like using a single state ratom, that state is global, and it needs to be managed with care. For small focused components that I want to re-use, sometimes multiple times on the same page, I will have that component use it's own local ratom to manage it's state.
I really gotta take some time to understand reframe cuz it’s been beyond my understanding in previous attempts. It seems really powerful
It is. Understanding reagent well help. If you find yourself doing a lot of work with a single global atom, and tracking and updating that atom starts to become unwieldy, maybe then it will be time to consider re-frame.
I’m currently refactoring a somewhat messy reagent app that has a single global atom and then a bunch of namespace atoms which makes for a lot of complicated updates and hard to reason about code paths
Seems like an appropriate time to try reframe!
Thanks for the advice
Indeed. Good luck in your refactoring. Be sure to check out the #re-frame channel
Thanks for the suggestion, the reframe tutorial on their site is much improved since I checked it out a couple years ago. I think it’ll work great for me!
To follow up on that question, I read the docs and saw that cursors can take swap! and reset! calls, which act as swap! update-in calls on the base r/atom, which neatly handles my use case