-
Notifications
You must be signed in to change notification settings - Fork 87
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
Add pathvars
& body
in the store
#152
Conversation
pathvars
& body
in the storepathvars
& body
in the store
Hi @xurei thx for you PR. I need time to test you solution, but I like your proposal. 👍 |
@xurei you code in 0.10.7 |
Thanks :-) Just thought about something though. If you bind multiple actions to the same store, that might create some weird behaviour... Any idea how we could improve the implementation for such cases ? BTW, I made a react component based on your package : redux-api-react-switch |
@xurei Can you write example of weird behaviour? redux-api-react-switch is very interesting project 👍 |
I'll create an issue with the details ;-) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ultimately the tests are constructed wrong. The actual actions are not dispatched in the format you specified in the tests.
I don't know the codebase good enough to tell if you could or should import the actual action creators or not.
I fixed it to work with the provided action creators in my local copy. I would start working on a PR if this is indeed currently bugged with the provided action creators
@@ -14,21 +14,20 @@ export default function reducerFn(initialState, actions={}, reducer) { | |||
const { actionFetch, actionSuccess, actionFail, | |||
actionReset, actionCache, actionAbort } = actions; | |||
return (state=initialState, action)=> { | |||
const params = action.params || {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Params are stored in action.request.params. This is currently always defaulting to {}
src/reducerFn.js
Outdated
switch (action.type) { | ||
case actionFetch: | ||
return { | ||
...state, | ||
pathvars:{}, | ||
body:{}, | ||
pathvars: action.pathvars || {}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here. Pathvars are stored in action.request.pathvars. This is currently defaulting.
Hi @eps1lon I'll be glad to see new PR with bug fixing 👍 |
It would be useful to have the path vars and/or the body of the request in the store. I personnaly use those information to detect if the data needs to be fetched again.
Here is my proposal for such feature.