Closed gangstertim closed 8 years ago
+1
No, feel free to use your stores either as singletons or as instances.
The only con to this particular method I see is that a bunch of stores would be instantiated at runtime when the file is evaluated. This is probably not bad in itself but maybe you'd like to dynamically construct/destroy stores?
It seems that the overwhelming preference is to keep stores as singletons. When they'll be used by multiple components simultaneously, the recommendation has been for components to pass a key to the store, and for the store state to be a map mapping keys to individual states.
That all works just fine, though sometimes gets just a little bit messy because of the prevalence of deeply-nested objects.
We're considering a non-singleton pattern whereby stores that are consumed by similarly-structured components are instantiated in connnected components. IE,
This pattern allows us to remove a layer of nesting from our store, which is nice! Is there any compelling reason NOT to do this?