These are chat archives for reflux/refluxjs

14th
Aug 2015
Adrian Chen
@ChennyBaBy
Aug 14 2015 09:34
Does anyone draw out their reflux on a diagram or any sort before code? I've been using pen and paper, was wondering if anyone else do this out there. and what tools or app you arrange the diagram with~
Ben Vinegar
@benvinegar
Aug 14 2015 18:57
hey folks
ive got an issue with reflux that ... seems less than ideal
basically, i have a store connected to a component via Reflux.connect
the store is basically manipulating an array ... and when the array contents change, i call (from the store) this.trigger(this.arr);
however ... i push to the array; i dont recreate it ... and as a result, the component gets a reference to the array
everytime i push to the array, before calling trigger, the component already "has" the new item because it has the same array reference
then when reflux calls setState on the component, the component looks at the new values, sees that they are already in its array, and doesn't call render
my questions are 1) is this known documented behavior somewhere ... 2) is this considered a bug? ... or 3) should i work around this by, say, making sure they have different arrays
Ben Vinegar
@benvinegar
Aug 14 2015 19:08
@spoike
Julien Phalip
@jphalip
Aug 14 2015 19:30
@benvinegar I suppose you would need to change it so that the store completely owns the array ("source of truth"), and let it pass the array down to the component. In other terms, the component should not hold any permanent reference to that array.
Ben Vinegar
@benvinegar
Aug 14 2015 20:19
@jphalip that's what i did
but, it seems to me, this is something that is easily tripped up on
and should at least be documented, if not possibly "fixed"
Julien Phalip
@jphalip
Aug 14 2015 22:52
Hello there. So I had a question about the initial hydration of a store. Is it possible to load initial data into a store before the associated component's first render?
That data is fetch via Ajax, by the way. So I don't know what the initial data is until the round-trip from the server is complete.
Also, I'm asking this in the context of server-side rendering. When the page is first loaded, the HTML has already been rendered but I need to reload the data to set all the even handlers.
And the problem I'm having is that the component is first rendered with an empty state, clearing everything on the page, before repopulating the page once the store has finally reloaded the data.
So what I'm trying to do is hold off on the initial client-side render until we have fully loaded data into the store.
Any tips?
So far the only way I've been ale to achieve this is by passing the initial data as a prop — see "version 2" in this gist: https://gist.github.com/jphalip/16ed71b08c493f45072c