TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Redesigning Redux

80 pointsby ShMcKabout 7 years ago

19 comments

tomeldersabout 7 years ago
The strength of redux is that all your interactions with it are through functions. Redux today is far better than the Redux of yesteryear thanks to things like ReSelect, Thunks, Sagas, Higher Order Components etc. All these things augment Redux, and they can do so because of Redux&#x27;s open embrace of the humble pure function.<p>Once you commit to a config based approach, you&#x27;re basically closing the door to a future you can&#x27;t imagine yet. I&#x27;m so tired of this short-sighted obsession with configuration some developers seem to have.<p>I think the author has a myopic vision for where Redux should go.
评论 #16522453 未加载
woahabout 7 years ago
While Redux is great because it enforces a single source of truth, the whole thing with &quot;actions&quot; and &quot;reducers&quot; in Redux is a huge source of boilerplate. In almost every Redux project I have worked on, developers bring in some weird scheme to reduce the boilerplate load of having to come up with a bunch of events when all that anyone wants to do is call some functions.<p>The fact that Redux forces you to use events to modify the store is a useless complication which has spawned reams and reams of crazy libraries like redux-thunk, redux-saga, standard action formats, etc. The craziest thing yet is Ducks: <a href="https:&#x2F;&#x2F;medium.freecodecamp.org&#x2F;scaling-your-redux-app-with-ducks-6115955638be" rel="nofollow">https:&#x2F;&#x2F;medium.freecodecamp.org&#x2F;scaling-your-redux-app-with-...</a>. This is a pattern which tries as hard as possible to make using events not feel like using events, by tying each event intimately to its listener.<p>This library is a step in the right direction, but wrapping Redux seems unnecessary. Here&#x27;s a similar approach in 100 LOC: <a href="https:&#x2F;&#x2F;github.com&#x2F;didierfranc&#x2F;react-stateful" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;didierfranc&#x2F;react-stateful</a>
评论 #16528090 未加载
评论 #16524635 未加载
agentultraabout 7 years ago
&gt; You don’t need to understand what a “comonad” is to use jQuery, and you shouldn’t necessarily need to comprehend functional composition to handle state management.<p>Is there a point to spreading this piece of sage FUD?<p>It should not be surprising that pure functions + immutable state results in fewer errors.<p>The &quot;pattern&quot; Redux asks you to use prevents you from shooting your leg off. If you&#x27;ve written a sizeable application that uses global, mutable state the benefits of Redux shouldn&#x27;t be surprising.<p>My only gripe with this eco-system is that it constantly comes up with new names and concepts for things that already exist in the FP world. I agree that the math jargon is off-putting but so is having a dozen words for the same concept. I think the latter is worse.<p>The library described in the article feels less like an abstraction and more like a shuffling around of syntax. Useful but misleading with a title like, <i>Redesigning Redux</i>.<p><i>Update</i>: s&#x2F;grip&#x2F;gripe
评论 #16522460 未加载
评论 #16522491 未加载
halayliabout 7 years ago
&gt; Consider time_saved to represent the time you may have spent developing your own solution<p>Developing your own solution is one thing, and developing your own solution that&#x27;s as battle tested as a popular library is another.<p>Baking your own solution helps you understand the core problem that a library you could have used tried to solve. But generally speaking developers that tend to do that have difficulty learning top to bottom and favor bottom up approach which leads them to developing things from scratch. That&#x27;s just a personal anecdote though.<p>There are cases were a developer has been using a library for a while and is experienced enough to come up with better solution and cleaner APIs but I&#x27;d argue that&#x27;s not the common case.<p>Understanding other people&#x27;s code&#x2F;libraries is a skill worth mastering.
评论 #16522230 未加载
评论 #16522331 未加载
评论 #16522309 未加载
kenforthewinabout 7 years ago
Is Redux too complex? That&#x27;s the central argument this article makes but I find it to be patently false. What drew me to redux was its simplicity: Abramov said from the beginning that it&#x27;s not anything you can&#x27;t code yourself, it just provides a thin framework around making changes to some base state object. Its main strength (to me) is that it forces developers to think about state changes as mutations rather than recreating a spaghetti state machine oneself.
评论 #16522844 未加载
r00nb00mabout 7 years ago
Nothing on this project solves the real problems and introduces different ones, like how to have a reducer respond to different actions. My quibble with React is that when you get into moderately complicated forms, you start sprinkling stuff all over the place to get the desired output. Take for instance the most popular form library, redux-form. It&#x27;s very heavy on it&#x27;s own way of doing things, and there&#x27;s a lot of stuff you have to know about it to be able to read into what the hell is going on, and it&#x27;s hard to keep shit in the same place. Reselect is also very heavy handed for what it does. I NEVER needed anything like reselect before redux, and it kinda went alright! In my experience, for any reasonable development with redux you have to introduce: reselect, redux-form, thunk, some sort of immutability (immutable or redux-orm), a sprinkle of compromises and plenty of boilerplate, or roll your own magic util functions (i actually rolled my own very similar stuff to rematch, for quick and dirty stuff). When you summarise all that, it&#x27;s really not that simple anymore! By the time you get through all of that, you might aswell pick up angular with the added benefit of clearer best practices, nicer dependency injection (oh, but react calls it context so it&#x27;s cooler!), familiarity and type safety.<p>It&#x27;s kinda funny how redux succeeded with such heavy concepts, which is normally not the case. This is still a mistery to me.<p>Oh and don&#x27;t get me started on HOC. Want a tooltip over your component? Sure, wrap it in tooltip HOC! Sooo much nicer than directives!
danpalmerabout 7 years ago
This looks nice, although in Redux&#x27;s favour is a large ecosystem of libraries that will work with it. This highlights a problem I still have with the JS ecosystem, which is relatively tight coupling between libraries. Of course many of these libraries could be glued together manually without too much work, but with the rapidly changing ecosystem and APIs for interoperability between libraries, and the obscurity of some of the libraries (Redux being a good example), this is often just not practical.<p>Compare this to Elm and the Elm architecture, and it seems worlds apart. Interoperability between libraries that all works in the same straightforward way, checked by the compiler.<p>It feels like the JS community made a lot of good decisions for the right reasons, but still ended up in a place that isn&#x27;t great.
评论 #16522109 未加载
评论 #16522669 未加载
wwqrdabout 7 years ago
Seems kind of like replacing common functional patterns with esoteric configuration objects?
eroppleabout 7 years ago
I&#x27;ve never really understood the point of redux-thunk. But, then, I also don&#x27;t use asynchronous actions <i>in my datastore</i>.<p>Asynchronous actions feel, to me, that they belong at the component layer where niceties such as spinners are being rendered, and then the backing store is updated with the results of the triggered action.<p>What drives people to put all of that into their store?
评论 #16522409 未加载
评论 #16522347 未加载
评论 #16522342 未加载
评论 #16522415 未加载
评论 #16522246 未加载
评论 #16522272 未加载
vanderZwanabout 7 years ago
&gt; <i>Is Redux more performant? No. In fact, it gets slightly slower with each new action that must be handled.</i><p>This point is not revisited. What is the performance of Rematch in comparison to Redux? I mean I guess it&#x27;s more or less the same, since it&#x27;s essentially Redux with less boilerplate, but it would be nice to have an explicit answer to this.
Longwelwindabout 7 years ago
Can someone explain to me why someone would choose Redux over something like MobX ?<p>I feel like implements an action for each modification of state (or group of modifications) requires a lot of boilerplate code. In MobX, you treat your data tree as a separate entity, and simply modify it. The UI is automatically updated whenever it needs to.<p>Mobx isn&#x27;t bad performance-wise, I think, since it only re-renders the components that are listening to the modified variables when a modification occurs.<p>The only advantage I see is being able to rewind the state store, which can be quite cool when debugging.<p>I have done some medium-sized application (only games), and I don&#x27;t think I&#x27;ve run into any performance or readability problem with MobX. I&#x27;ve never done web apps with a team, though, but I don&#x27;t think Redux would specially make it easier to work with other programmers.
评论 #16525205 未加载
chncdcksnabout 7 years ago
(To preface, I use React&#x2F;Redux in all of my web applications. I think Redux is great for managing state.)<p>One thing I’ve never quite understood about Redux is why we are dispatching pure data instead of a function of state. This would remove the need for reducers, since your action _is_ your reducer. Something like this...<p><a href="https:&#x2F;&#x2F;gist.github.com&#x2F;anonymous&#x2F;a5d741c5dec81be61e0aa708200b53d1" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;anonymous&#x2F;a5d741c5dec81be61e0aa70820...</a><p>Would this come with any drawbacks? I could see a large application having performance issues because of a large number of function allocations, but for small applications I don’t see a downside, just a simpler API.
评论 #16522592 未加载
senoroinkabout 7 years ago
This article resonated with me fairly well. As someone who has had an extensive background in Rails and has more recently switched to 100% javascript, this kind of pattern is what the community needs. There&#x27;s something to be said about getting up and running as quickly as possible. Sure you can make the argument that not everyone&#x27;s application is the same, but there&#x27;s a ton of similar patterns that would have been better suited to having less mental gymnastics with a simple config while still leaving the door open with FP for those that want to fine tune.
myguysiabout 7 years ago
Isn’t one of the points of redux to decouple actions from reducers? How would you implement multiple reducers responding to a single action if your actions are tied to a reducer with a namespace?
评论 #16522553 未加载
评论 #16522555 未加载
heygradyabout 7 years ago
Rematch reminds me of Marty.js. I like some of the ideas about providing a createStore wrapper that is more zero-config and using something like redux-actions to make reducers simpler. I have been using my own wrapper around sagas to allow for dispatching effects.<p>They lose me with their idea of &quot;models&quot; where I have a global dispatch that can be extended, like dispatch.modelName.actionName. That&#x27;s just old school object-oriented thinking layered on top of redux&#x27;s functional programming ideals.
评论 #16522161 未加载
mplewisabout 7 years ago
This approach looks really similar to the VueX approach: synchronous reducers are mutations, and async effects are actions. Can&#x27;t wait to try this out in my next React project.
pluto9about 7 years ago
Nice. I&#x27;ve thought of some of these myself and implemented them as helper functions, but there are some new ideas here I hadn&#x27;t thought of. Not sure I&#x27;m ready to port my project to a new library, but I may try some of these out piecemeal.
davedxabout 7 years ago
I like it. Configuration should be just that. Interested to read other opinions.
castlegloomabout 7 years ago
should have known it was a ploy for yet another library.