Description
Hello,
first of all I'd like to thank you guys for all the hard work on feathers-plus repos. I'm using feathers-redux in a project and it's really great. 👏
Recently I came across what I believe to be an unexpected behavior. I thought about submitting a PR, but first I'd like to clarify my issue with you and see if it's really unintended behavior.
Code to be executed
dispatch(reduxServices.serviceName.reset(payload));
Expected behavior
I'd expect the reducer to be updated to hold the payload passed as argument in queryResult. Like:
{
isError: null,
isLoading: false,
isSaving: false,
isFinished: false,
data: null,
queryResult: payload,
store: null
}
Actual behavior
Instead queryResult is always kept to whatever it was set before the call to reset method.
{
[...]
queryResult: queryResultPreviousValue,
[...]
}
Code in question
https://github.com/feathers-plus/feathers-redux/blob/6a10bd9/src/index.js#L197-L214
In Redux, all actions are dispatched passing to reducers their current state along with the action object (with its payload, type, and whatnot). With that in mind, I think the following line:
[opts.queryResult]: action.payload ? state[opts.queryResult] : null,
Should rather be:
[opts.queryResult]: action.payload,
So we set queryResult to whatever is passed to the reset method call allowing coders to set arbitrary values to it. state[opts.queryResult]
will always keep the same value queryResult is already defined to.
Am I wrong in my assumptions or analysis?
Let me know if I can clarify or elaborate on anything.
Thank you!!!