Fork me on GitHub
#reagent
<
2016-08-24
>
cemerick14:08:56

I'm using cursors to constrain the scope of access/visibility each component instance has, but all of my components are being rebuild / updated on each change within the ratom, even those outside of the scope of their cursor

cemerick14:08:21

is that expected, or am I perhaps doing something to make reagent think components are dirty when they're not?

pesterhazy14:08:12

are you using a cursor or a ratom?

pesterhazy14:08:33

ah sorry, a cursor based on the ratom

pesterhazy14:08:06

no, your assumption is correct - only changes within the scope of the cursor should mark the component as dirty

pesterhazy14:08:02

probably something you're doing elsewhere -- hard to say without seeing the code

cemerick14:08:13

So, I have components A, B, and C that contain each other in that order, and which narrow scope with a cursor at each step. C is the only one that swaps on its cursor. I'm a little lost on how those operations could escape that scope.

cemerick14:08:41

I should produce a minimal example, but there's a ton of non-react, non-reagent stuff around this bit...

pesterhazy14:08:52

so what counts is where the cursor or ratom is dereffed; it doesn't matter where it's swapped

pesterhazy14:08:39

reagent's render fn are wrapped in (pseudo-code): (track-which-ratoms-are-dereffed (your-render-fn))

cemerick14:08:16

sure, only deref or swap is in C

cemerick14:08:37

only interaction A and B have is to make a cursor

pesterhazy14:08:01

that should work

pesterhazy14:08:11

how do you know that A and B are re-rendered? have you added logging to the render fns to make sure?

pesterhazy14:08:56

oh and of course if you deref the ratom anywhere in A or B, those components will rerender

pesterhazy14:08:17

as the cursor is just a view on the ratom

cemerick14:08:55

okay, well at least that confirms my expectations

cemerick14:08:20

I'll go see if I can produce a minimal sample. Will probably find the problem along the way 🙂

pesterhazy14:08:17

oh and make sure you're calling render-component only once

danielcompton21:08:24

@cemerick hard to tell if this is the problem, but in case you’re not familiar already, take a look at https://github.com/Day8/re-frame/wiki/Creating%20Reagent%20Components