Mobx: How to inject store into an other store?

Created on 24 Oct 2017  路  1Comment  路  Source: mobxjs/mobx

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.

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.

>All comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fibric picture fibric  路  37Comments

bySabi picture bySabi  路  95Comments

Kukkimonsuta picture Kukkimonsuta  路  65Comments

mweststrate picture mweststrate  路  105Comments

davidmoshal picture davidmoshal  路  30Comments