|
|
|
|
|
by mdc2161
3715 days ago
|
|
I just started with redux-saga which uses ES6 generators to handle app control flow. After first impressions, I'd say it's worth a look if you're running into anything near as complicated as talked about here. It's very easy to reason about and test. gaearon - the creator of redux - seems to approve of it as well. https://github.com/yelouafi/redux-saga |
|
Saga is making side-effects (workflows) possible by subscribing to events.
So in this case I have a saga waiting for 'SEARCH_FORM_UPDATE', then it waits for 300ms, then starts the ajax request flow: a request start action, then a request complete action (or request error).
The code reads almost like synchronous code once you understand yield.
It also allows you to listen to actions that you do not control: we wanted to do something whenever a specific redux-router action happened. You can't do this with thunks, we would have needed a middleware to do this. With sagas you can simply hook up a flow to the action.