You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are a lot discussions going on in the ReduxJs community regarding side effects and how they should be handled. And I think we should incorporate what we think of as best actions into the core project (we don't have an example of how it can be achieved in our docs currently).
From what I've gathered there are currently 3 options:
1: Action Creators
2: Reducers
3: Middleware
1: Dan Abramovs initial suggestion is to implement side effects in Action Creators. However, a lot of people find this to become messy quite quickly.
Personally, I also find it hard to figure out how to structure my application properly. If most actions are simple, and some are huge complex chunks of code, I find it hard to jump into an application and figure out where to find API logic fx.
2: The following discussion highlights why using Reducers for side-effects is a bad idea: reduxjs/redux#291. And personally I agree. Reducers should change state objects, but not dispatch side effects. If we start putting side effects in some reducers and not in others, it will quickly become hard to track how information flow through the application.
3: Middlewares: There are quite a few examples of middlewares handling sideeffects in Redux - one of them is https://github.com/yelouafi/redux-saga. Personally I lean towards this approach. I dislike the name - because it has no semantic meaning ot me. But the idea of having services, that catch actions before they're passed on to reducers, is an appealing one.
Personally I would structure them as services in the application, so that all the side effect logic is located in one place. Disclaimer: I haven't read the Saga documentation in detail, so I might have a different mental picture what it's actually doing.
I'm going to keep updating this thread as I read through the documentation of all the different solutions. But feel free to pitch in in the meantime!
The text was updated successfully, but these errors were encountered:
There are a lot discussions going on in the ReduxJs community regarding side effects and how they should be handled. And I think we should incorporate what we think of as best actions into the core project (we don't have an example of how it can be achieved in our docs currently).
From what I've gathered there are currently 3 options:
1: Action Creators
2: Reducers
3: Middleware
1: Dan Abramovs initial suggestion is to implement side effects in Action Creators. However, a lot of people find this to become messy quite quickly.
Personally, I also find it hard to figure out how to structure my application properly. If most actions are simple, and some are huge complex chunks of code, I find it hard to jump into an application and figure out where to find API logic fx.
2: The following discussion highlights why using Reducers for side-effects is a bad idea: reduxjs/redux#291. And personally I agree. Reducers should change state objects, but not dispatch side effects. If we start putting side effects in some reducers and not in others, it will quickly become hard to track how information flow through the application.
3: Middlewares: There are quite a few examples of middlewares handling sideeffects in Redux - one of them is https://github.com/yelouafi/redux-saga. Personally I lean towards this approach. I dislike the name - because it has no semantic meaning ot me. But the idea of having services, that catch actions before they're passed on to reducers, is an appealing one.
Personally I would structure them as services in the application, so that all the side effect logic is located in one place. Disclaimer: I haven't read the Saga documentation in detail, so I might have a different mental picture what it's actually doing.
I'm going to keep updating this thread as I read through the documentation of all the different solutions. But feel free to pitch in in the meantime!
The text was updated successfully, but these errors were encountered: