Closed k-ode closed 3 years ago
If mobx-state-tree soon will support lazy loading (current PR), I think it would be really useful it the user could create a custom root store.
createRootStore({ MessageModel: [types.lazy(() => MessageModel), 'messages'] UserModel: [types.lazy(() => UserModel), 'users'] }); // which would return something like const RootStore = types.model({ messages: types.map(types.lazy(() => MessageModel)), users: types.map(types.lazy(() => UserModel)) }).actions(self => ({ update(typeName: string, data: any) { self[types[typeName]].put(data); } });
This would solve a lot of issues that arise from normalized objects not being part of the same state tree.
It might be worthwhile to support this anyway. Could make mst-query more useful for projects that don't care about bundle size.
If mobx-state-tree soon will support lazy loading (current PR), I think it would be really useful it the user could create a custom root store.
This would solve a lot of issues that arise from normalized objects not being part of the same state tree.