This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-08-23
Channels
- # announcements (2)
- # beginners (246)
- # boot-dev (1)
- # braveandtrue (3)
- # calva (13)
- # cider (26)
- # cljs-dev (6)
- # clojure (75)
- # clojure-finland (4)
- # clojure-germany (39)
- # clojure-italy (1)
- # clojure-mexico (1)
- # clojure-nl (14)
- # clojure-spec (61)
- # clojure-uk (104)
- # clojurescript (125)
- # cursive (20)
- # datomic (1)
- # emacs (2)
- # figwheel-main (91)
- # fulcro (29)
- # graphql (9)
- # jobs (3)
- # jobs-discuss (9)
- # juxt (13)
- # liberator (2)
- # luminus (1)
- # off-topic (15)
- # parinfer (8)
- # re-frame (70)
- # reagent (35)
- # reitit (24)
- # remote-jobs (5)
- # ring-swagger (3)
- # shadow-cljs (127)
- # spacemacs (34)
- # yada (6)
Hmmmm, maybe 'cursors' is the typical/standard means for addressing this?
@jsa-aerial yeah that’s not always true. You can have cursors and other sorts of reactions that derive from some subset of the single ratom state. These constructs can intelligent avoid re-notifying watchers, eg re-rendering, when the change doesn’t result in a difference derived value.
@mikerod I see - sort of - what are these 'intelligent constructs'? Another idea I had is to have ratoms in the main ratom to differentiate these things. Since changes to these 'sub' ratoms would not change the value of the containing ratom, that might be a workable solution.
@jsa-aerial There are other constructs beyond the ratom
those can derive from data based on a ratom and there are built-in checks they perform to ensure that what they depend on has indeed changed
like a rcursor will only depend on a value at a path in the ratom (or reactive thing it depends on)
and if the value at that path hasn’t changed, then the watchers (eg would be component renderers) of the cursor won’t be updated
In the case of ratom’s, if the value at the path is identical?
watchers aren’t notified
That, seems to no longer be true from reagent 0.6+ it appears to use =
for change in ratoms
Doesn’t look like it here for a cursor at least https://github.com/reagent-project/reagent/blob/v0.8.1/src/reagent/ratom.cljs#L259
sorry, reactions have 2 sides, the incoming data is compared via identical?
I think, the outgoing result is using =
https://github.com/reagent-project/reagent/blob/v0.8.1/src/reagent/ratom.cljs#L418
this is what I think you are referencing from the 0.6 changelog
yeah - that must be the 0.6 change I had seen.
Right - but do these (other than 'cursors') exist in reagent or some lib or are these typically hand rolled?
https://github.com/reagent-project/reagent/blob/master/doc/ManagingState.md docs on some
Ah... I will look at that - only in the code?
That, seems to no longer be true from reagent 0.6+ it appears to use =
for change in ratoms
Not that that makes a difference in this context...
Ah... I will look at that - only in the code?
I thought I read all of that but I may have stopped after cursors. :thinking_face:
I’m a fan of re-frame
nowadays. The default there is for a single ratom to hold all of the app state
re-frame
uses reactions to based derived views on the single app state data. Re-renders are avoided due to this change detection built into the reactions
regardless of if you want to use re-frame
or not, there are a few good docs there about this topic. This section stands out https://github.com/Day8/re-frame/blob/master/docs/SubscriptionFlow.md#how-flow-happens-in-reagent
I see - was thinking of looking into re-frame as a mid-term thing, but maybe need to bring that forward. All that reaction stuff (with the numerous protocols) is rather low level and complicated. Nice to build something with - apparently like re-frame....
over time I started buying into the re-frame
ideas more and more and I switched to it for future app’s and also uplifted the larger reagent
one I had. One main reason is I like the better prescribed structure and “life cycle” of re-frame
reagent
alone, to me at least, is more of a “do it yourself”.I still think you’ll wind up creating some sort of “framework/architecture” around the reagent
constructs anyways - so it just comes down to if you like re-frame
s model or not
On that note, here you go https://github.com/Day8/re-frame/blob/master/docs/FAQs/DoINeedReFrame.md
@jsa-aerial I totally agree with what @mikerod says above. For me, I just follow a fairly simple and rigid practice of “subscribing” to the data I need in the main ratom by creating cursors in a let-block to the specific paths I need for any given component. this keeps its rerender minimal and has the side benefit of making it easy to see what data a component depends upon. I think re-frame does this or something similar with its subscription mechanism.
Thanks for the insight everyone! I think what I missed was the rerendering. We might explore cursors to make it more specific, so non-reframe-subscribed field components can still “work” when you type text.