Fork me on GitHub
#rum
<
2016-11-27
>
kauko10:11:54

Any idea whether it's better to try to give most arguments as atoms and use the reactive mixin, or try to use immutable data structures and the static mixin?

kauko10:11:50

My guess would be that the reactive mixin offers better performance, since Rum doesn't have to do an equivalence check on every component, but I'm just guessing

niwinz10:11:16

passing atoms as arguments will not save you from using static mixin,

niwinz10:11:46

because if some top component need rerender will cause whole tree rerender that is something you may don't want...

niwinz10:11:53

On my apps I'm using two approaches, for big page like components I use reactive mixin and just take the atoms/refs from the namespace where they are definen. For small reusable components I'll try to use static+immutable data structures as arguments

niwinz10:11:05

making them rerender only when their arguments change.

kauko12:11:11

Why does a top level component cause all child components to rerender? Wouldn't Rum know that they don't need to be rerendered? I think Reagent does, so I expect to Rum to know too

kauko12:11:41

I could be mistaken - it's hard to tell what exactly causes a component to re-render, unless you have logging that explicitly tells you that..

niwinz12:11:57

if you don't use the static mixin, the shouldComponentUpdate by default is true, (the reacts default), so if something in top level component is changed, it will trigger the render of each child component, unless the shouldcomponentupdate returns false

niwinz12:11:11

this I think works in the same way in rum and reagent

niwinz12:11:31

and it is not related to atoms or something similar, it is just the default behavior

kauko12:11:09

From here I understand that Reagent checks for equivalence in the should-component-update-method

niwinz12:11:19

so, reagent has the static mixin behavior by default

niwinz12:11:28

or something similar

kauko12:11:59

So I guess in Rum, if I have a component that gets all its arguments in an atom, and I want to react to changes in that atom, I should in fact use both the static and the reactive mixin..

kauko12:11:26

Reactive mixin for reacting to changes in the value of the atom, and static for telling the component only to re-render when it gets a different atom as arguments

niwinz12:11:50

static is about arguments and reactive is about watching atom changes

niwinz12:11:14

static mixin checks the arguments and decides if it need render or not based on equality

niwinz12:11:03

so if some toplevel is need to be rerender it will call the child component with the same atom, then, the child component not will be rerendered