Comments (5)
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.
from prism.
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).
Actually take
or takeEvery
can take predicate as an argument therefore this custom logic can be implemented in Sagas as well... the question is though, should this be part of the framework? Since I believe that this should live in userland.
One use case would be a global 'REFRESH' action fired in the app that would need each component saga to fetch their data again.
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.
from prism.
Could you provide some code snippet about what you have envisioned?
from prism.
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);
from prism.
Closing, solved by Saga & matchers decoupling in v3.
from prism.
Related Issues (20)
- Don't Call PropTypes HOT 3
- Sibling components interaction best practice HOT 6
- Performance HOT 2
- Request to join cdnjs HOT 1
- Build a umd package for Browser usage
- Reduce bundle size by using rxjs modularity HOT 1
- Mount order and saga registering HOT 8
- Get currentUser state in component Updater HOT 3
- Sagas not getting unmounted HOT 2
- Version 4.x.x HOT 7
- redux-saga update HOT 2
- Documentation links 404 HOT 5
- Where is documentation for v3? HOT 2
- Props 'selector' and 'wrapper' get passed down to enhanced component HOT 3
- prism-redux/escapeRegexp.js is missing a character in the regex
- Questions about using side-effect libraries with prism
- How to wrap/unwrap dynamic components? HOT 2
- Provide a wrapper compatible with the library-provided unwrapper
- EnhanceComponent doesn't work with thunk middleware
- Dynamic list of stateful components HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from prism.