News for hackers. Stuff that matters.
Re:How to optimize React applications that use Redux by beefsack on Wednesday July 05, 2017 @07:01PM (#14706844)
In my experience, Redux seems to fit better with those coming from a FP background, and MobX seems to sit well with those with OOP backgrounds.
Re:How to optimize React applications that use Redux by acemarke on Wednesday July 05, 2017 @07:10PM (#14706901)
Yep, absolutely true.

Preethi Kasireddy did a fantastic presentation at ReactConf comparing Redux and MobX [0], Robin Wieruch wrote a good article comparing them last year [1], there was a Reddit thread with good discussion as well [2], and I have links to more comparisons at [3].

They're different tools taking very different approaches to solving the same kinds of problems, and they definitely appeal to different developers.

[0] https://youtu.be/76FRrbY18Bs

[1] http://www.robinwieruch.de/redux-mobx-confusion/

[2] https://www.reddit.com/r/reactjs/comments/4npzq5/confused_re...

[3] https://github.com/markerikson/react-redux-links/blob/master...

Re:How to optimize React applications that use Redux by shados on Wednesday July 05, 2017 @09:28PM (#14707530)
Yup. Redux also fits better people who like more vanilla code at the expense of verbosity. MobX fits better people to prefer terseness.

Redux falls apart pretty hard when people start layering sugar and abstractions on top. It's my pattern of choice, but for teams that insist on abstracting the Redux boilerplate away, I steer them to MobX.

Re:How to optimize React applications that use Redux by acjohnson55 on Wednesday July 05, 2017 @07:12PM (#14706914)
Yep. Redux does a great job of pushing mutation out of your application logic and into the library machinery, much like React does. Together, you get logic that's remarkably pure. It makes for an application that's dead simple to debug.

I've never tried MobX, but it looks pretty impressive too. I can imagine it working really well if you have the discipline to not leak your mutations all over the place.

Re:How to optimize React applications that use Redux by aidos on Wednesday July 05, 2017 @07:29PM (#14707022)
MobX (in strict mode) forces you to annotate your mutations (via the @action decorator).

MobX is useful mostly as the data model / selector part of redux. It does an awesome job of it. Once you've defined your core data model, you can create layers of computed properties and transformations out to your view. The view then rerenders in a really optimal way.

Where redux shines is the prescriptive nature. The layout of a redux app is fairly well defined at this stage and there are "right" and "wrong" places to put (and look for) different types of code.

With MobX there's still no clear way to layout your application, so, as you say, you need to be more disciplined with your approach.

Re:How to optimize React applications that use Redux by shados on Wednesday July 05, 2017 @09:26PM (#14707525)
Redux isn't really that prescriptive (and it's a problem). Since middlewares let you do pretty much anything, people will do the silliest things.

Vanilla Redux that somewhat closely mimics the Elm architecture is fantastic at it, but average Redux apps in the wild are...mediocre at best.

Re:How to optimize React applications that use Redux by pknopf on Wednesday July 05, 2017 @11:27PM (#14707956)
Also, with Mobx, you get absolutely perfect rendering update performance. You literally can't do it any better, thanks to observables.

You literally can't fuck up rendering performance, provided you don't have a single huge component the renders your entire state.

Re:How to optimize React applications that use Redux by bpicolo on Wednesday July 05, 2017 @07:38PM (#14707078)
I've found the opposite. Coming from FP like Clojure, Redux just feels unwieldy in comparison, whereas MobX feels like it fits the language/problem better (but has plenty of it's own issues)