Comments (3)
Hi @anion155! Thanks a lot for you for taking the time for making these suggestions. 🙂
Add payload creator option to
createAction#withPayload
, for custom arguments in generated action creator. Also maybe add helpers likewithMeta
,error
for FSA compabillity.
Good idea! I was already considering that, but just didn't get around to it yet. Out of curiosity, are there any particular use cases you have for action metadata and/or the error
flag?
Create some form of middleware generator, with ho-functions mapped to corresponding action type. In my projects I'm using this construction:
declare function middlewareMappedByActions(): { onAction<T, A>(action: { type: T; (...args: any[]): A; }, middleware: (store: Store, next, action: A) => any): this; map(): (store: Store) => (next) => (action) => any; }; declare function middleBefore<A>(middle: (store: Store, action: A) => any): (store: Store, next, action: A) => any; middlewareMappedByActions() .onAction(actions.setHostStatus, middleBefore((store, action) => { // do staff }) .map()
I'm interested in learning more about how you use this. Do you have some examples where this helper was useful for you?
from redux-preboiled.
Out of curiosity, are there any particular use cases you have for action metadata and/or the error flag?
Not yet, sometimes it can used, but for me it was two or three this kind of actions, and in all my cases it's all was handled by middleware, 'cause I don't really like to store object like error or some mythic-non-typed meta information in store. But FSA is kind of standart already, and some people may found some good use for this.
from redux-preboiled.
I'm interested in learning more about how you use this. Do you have some examples where this helper was useful for you?
For the middleBefore
, it is just shortcut for:
store => next => action => {
// do staff
return next(action);
}
Similar middleAfter
:
store => next => action => {
const result = next(action);
// do staff
return result;
}
For the middlewareMappedByActions
, I think it's common case for middlewares that do staff on some types of action:
store => next => action =. {
switch (action.type) {
case 'SOME_AWESOME_ACTION_TYPE':
// do staff
return next(action);
}
}
Helper just creates map of handlers, and map
method returns middleware it self. I'm using it simple middleware declarations like export default middlewareMappedByActions...
. All helpers returns currying functions.
from redux-preboiled.
Related Issues (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 redux-preboiled.