DEV Community

loading...

Discussion on: Redux is half of a pattern (1/2)

salvoravida profile image
Salvatore Ravidà • Edited

You are missing the point, that "reducers" and "combineReducers" are de-facto the way of split a "global Store" into many "subStores" but with theese advg:

1) every "subStores" can listen every action/event and so react to that if needed
2) you have a centralized way to debug/control your app via DevTools.
3) you can access/interact with state outside of rendering lib-> think to channels, inter-framework communication - etc...

You can understand/debug all-business-logic of an "well-projected-redux-state" app, in few minutes, just opening Redux DevTools.

Moreover you can use As many Stores as you want, just as people use as many "React.Context" by using many <Provider !

The main advantage is to have 1 SINGLE "ROOT" of THRUTH!

Note "Root" not single Store.

That Said,
Decoupling business logic from render is something that every software architect should think about. Today react is the best rendering lib, but nobody knows tomorrow.

Redux and middlewares is perfect to Decoupling business logic from rendering.

WhatYouSee=Function<React>(state)

Just as Generics, tomorrow just change "React".

Thread Thread
davidkpiano profile image
David K. 🎹 Author

Okay, please keep using Redux however you'd like, thank you for your comments

Thread Thread
bradtaniguchi profile image
Brad

I do find it fascinating how there are very drastic responses to this post so far I must say. Some people agree that Redux is inherently "wrong", and other argue its inherently "right".

I'm like many, waiting for part two :D

Thread Thread
blocka profile image
Avi Block

The main advantage is to have 1 SINGLE "ROOT" of THRUTH!

Not sure about you, but in the types of apps that I write, I can not see any advantages of having a "single source of truth". In general, the complexity is always either at the page level, not the app level (the app is essentially just a router with some small global data, and an entity cache), or within some sub components on each page.

So I don't need a "single state atom" for anything. What I do need is to manage the state transitions of those complex components. Redux does nothing for me here. XState does tons.

I suspect most people are using redux as a global entity cache, or worse...what you do to store "global" data.