Hacker News new | comments | ask | show | jobs | submit login

This was an awesome read. We use React and Flux daily at work so I'm going to share this with coworkers. I'm a little confused on what the author's concern is though.

> I’ve just felt…well, weird. Something seemed off

Is there anything substantively wrong with the flux pattern or drawbacks?

EDIT: I changed that paragraph; thanks for pointing out it no longer fit with the rest of the post.

Original comment:

The weakness of typing in the switch blocks. I'll alter that sentence a bit; it's a leftover from an earlier version of that article where I was going to focus very narrowly on how uMsg/wParam/lParam, like the way actions are usually done in Flux apps, are decoupled to the point where it's very easy to make typing errors. Then I described why I thought they were similar to begin with, and then axed most of the original post when the entire thing switched to showing how Flux is an old pattern we've done before. I'll see if I can tweak that sentence in a way that keeps the flow going.

Using TypeScript's user defined type guards instead of a switch looks promising here, inside the 'if' the actions are type checked.

Or better, use Elm (or something similar) and tagged unions. That way you get type-checking and exhaustive-checking of your message types. You still have a big match (~switch/case) but now the compiler yells at you if you've forgotten to handle a message tag or if you're not unpacking the right types from it.

I agree. He does not say. That it's an old pattern is probably a testament to its strength.

I am using React/Flux (Redux) as well. I generally love it and find it easy to write dynamic UIs and without making very many mistakes. Each React and Flux component is small, focused, testable, and easy to reason about.

The only gripes I have are the small amounts of boilerplate I end up with. Redux cuts this down a lot over a homebrewed Flux implementation I wrote. Also, testing complex trees of components can be a bit of a drag.

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact