- How do two separate components access the one store, singletons?
- If two components observe the same store but render different attributes of it are they both updated when the store is updated?
- Are you limited to modifying your store only in your component?
You can use <Provider> and @inject to put a store onto the component tree and pull it off whenever you need it. It's just a quick wrapper around the React context API.
> If two components observe the same store but render different attributes of it are they both updated when the store is updated?
Yes, this is just how Mobx works. Observations are set up implicitly. You can observe any @observable value or @computed function just by referencing it within an @observer.
> Are you limited to modifying your store only in your component?
Nope, this works with just plain JavaScript. The main library doesn't offer any React-specific bindings (like Redux), so it can be used with anything.
For me? Basically all of that. Also now that code is highly dependent on the framework and tightly coupled.
Observables have their place for sure, I like them as a concept actually, but for me MobX is encoding an anti-pattern I try to avoid.
https://www.joelonsoftware.com/2001/04/21/dont-let-architect...
But the issue here with that is that I can solve the business needs in React+Redux trivially without running into the architectural problems I mentioned in MobX.
So why on earth would I chose the inferior option?
Example:
As you can see you just use the variables and get stuff for free out of the box with no plumbing code except `@observable` and @observer`. What's not to love?