I'm using the mobx real world example as a reference. (link: https://github.com/gothinkster/react-mobx-realworld-example-app/tree/master/src/stores)
How can I inject a store into an other store? I don't understand really well the concept of singleton, or rather, I don't know if export default new theStore() is enough to ensure we will only have one object possible or we should always rely on the provider's store to change anything.
If a store is implemented as singleton there will be only one store instance. Hence, the instance store will be the same whether access is being made through Provider Component or by importing the store directly.
On the opposite side, if there is no singleton, access will be made to different instance stores.
Check here for a good discussion on the topic and other approaches to this subject.
Most helpful comment
If a store is implemented as singleton there will be only one store instance. Hence, the instance store will be the same whether access is being made through Provider Component or by importing the store directly.
On the opposite side, if there is no singleton, access will be made to different instance stores.
Check here for a good discussion on the topic and other approaches to this subject.