Hacker News new | ask | show | jobs
by softfalcon 1551 days ago
MobX from a quick Google seems to resemble the old Knockout.js

We use Relay to define our state management, trigger global updates across many components, and also query/mutate our data.

Does MobX have a way to do the global state management that Relay does?

I’m curious because after using Relay, I’ve found most other types of state management to feel extremely heavy with boiler plate code.

Thoughts?

1 comments

One of the great things about MobX is that it works on plain data and plain operations on that data [0], not just the contents of a sanctioned Store, which means it has no opinions about where you put your data. Local objects captured by closures? Cool. Classes? Great. Mutating arguments? Go for it. Global singleton? Have fun.

[0] Technically, it wraps all the different data structures in Proxies etc as soon as they get assigned into an observable structure. But the goal is for you to never have to think about them as anything other than plain data, and that abstraction very rarely leaks.

Ah, that’s so cool! I will have to carve out some time to test this because that sounds really powerful and flexible!
It is! It can be overkill for very simple React apps, but I used it to build a power-user tool a couple years ago that would have been impossible to do with Redux or hooks.
Hooks are never the solution for state on their own. They're more for localized to a single component state.

That's why I brought up Relay (this is not the same as React, but works with React), cause it's what FB uses to stitch together global state between hundreds of different sub-components.

That being said, Relay does NOT have a simple object interactive state ability. It's an obscure "external store" with weird querying and mutating rules that can feel quite difficult to work with at times.