What is the best way to create a single MobX store for an app?
I use MobX for a year+ now and I basically do the same:
1) I have one "master" or "parent" store usually named as class Store {...}
2) Then I have some smaller stores that are kept in "master" store.
3) I prefer to construct children stores within master's store constructor. Moreover, I found that sometimes my child store has to observe some data from parent store, so I pass this
into child constructors:
class UserStore {...}class TodosStore {...}class Store { constructor() { this.user = new UserStore(this); this.todos = new TodosStore(this); }}
Parent keeps references to children, and each child has reference to parent.