Closed weblogixx closed 8 years ago
Hey @weblogixx, both ways are completely valid and I would say that you can use what feels right based on your personal preference.
That said, setState
was introduced to stores for a few reasons.
state
, we can create utilities that provide more functionality without having to provide configuration options for the shape of the store dataSo tldr; use whichever feels right to you, they both will get the job done, but storing store data on this.state
is probably best if you plan on using utilities like the immutable util
Hi @goatslacker,
first of all, let me thank you for this software. Alt really rocks and makes it much easier to create flux based applications.
I am a little bit confused about the different ways of setting values for stores. On your example pages, the data is set in the following way (which does work quite well):
This is the way I am currently using alt. Sometimes I also do multiple changes like
I have also read in some comments that the whole state should reside in single keys on the store class, but in a defined state property named
state
:In these cases, it is also said that the method
setState()
should be used to update the state changes.So my question is: What is the fundamental difference between those two assigns? Both seem to work without problems and are easily testable. However, in the getting started section the first variant is used, not hinting on the setState one.