-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom action matchers in Saga #16
Comments
Actually
I don't think this would be possible even with Custom matcher, maybe it wouldn't even make sense to implement it this way. I am in favour of explicit rather than implicit action wrapping in Sagas. |
I'm not sure what you mean exactly by "explicit rather than implicit action wrapping in Sagas". In Elm, the side effects are declared in the Updater so the way to take() actions that involve side effects is exactly the same as actions that just change the state. Even if in redux-elm the side effects are now declared outside of the Updater (e.g. in local sagas), I'd still expect consistency (and as much power) in the way I can take() actions and in the way they are wrapped or unwrapped.That's why I'm proposing to have the same custom action matchers this library provide for the Updater. |
Could you provide some code snippet about what you have envisioned? |
Since 3.x will support RxJS Sagas and action matching is totally separated from rest of the architecture in favour of #4 I can imagine we could nicely re-use the matching even in Sagas. const initialState = {
incremented: 0,
decremented: 0
};
const reducer = new MatchingReducerFactory(initialState)
.case('Incremented', model => ({...model, incremented: model.incremented + 1}))
.case('Decremented', model => ({...model, decremented: model.decremented + 1}))
.toReducer();
export default action$ => action$
.scan(reducer)
.filter(state => state.incremented >= 3 && state.decremented >= 3)
.map(() => ({ type: 'ShowPopup' }))
.take(1); |
Closing, solved by Saga & matchers decoupling in v3. |
Custom action matchers are available in the Updater but not in Saga. As I understand it, at the moment the saga can only take() an action that is local to the component (e.g. wrapped).
One use case would be a global 'REFRESH' action fired in the app that would need each component saga to fetch their data again.
The text was updated successfully, but these errors were encountered: