Closed amaury1093 closed 7 years ago
I agree the repo needs work in this area. I won't be able to get around to it until sometime in Jan 2018 because of work on Feathers Buzzard.
Are you interested in making a PR?
@amaurymartiny, I actually had this problem also have this implemented in a locally forked repo for testing and its working well. I could definitely submit a PR. Its actually a few lines of code.
Depending on the action you dispatch for the respective service, the state is changed to (`${actionName}Pending). For example, a create action (createPending: true), find action (findPending: true) ... (etc.).
const reducerForServiceMethod = (actionType, ifLoading, isFind) => ({
const slicedActionType = actionType.slice(SERVICE_NAME.length, actionType.length).toLowerCase() // returns find/create/update/patch
...
})
When the promise has started returns the following state as always with the following addition:
return ({
...state,
[opts[`${slicedActionType}Pending`]]: true,
...
})
When the promise has resolved:
return ({
...state,
[opts[`${slicedActionType}Pending`]]: false,
...
})
When promise is rejected:
return ({
...state,
[opts[`${slicedActionType}Pending`]]: false,
})
That is all the code, you can look at this file for reference (https://github.com/bsubedi26/React-Node-Authentication/blob/master/src/lib/feathers-redux.js).
Looks good! Yes go ahead and submit the PR
+1 I love not working in a vacumn.
Pull Request (https://github.com/feathers-plus/feathers-redux/pull/39).
I asked on the PR is the failing integration tests could be fixed.
Would it make sense to remove isSaving/isLoading after #39?
Quite possibly. Such a change should have a major semver change.
I plan to get my mind back into this repo in Feb once I finish some other Feathers work.
Proposal:
Motivation
I often do the following, in my React component, to do something when a resource has been loaded.
However I wish to differentiate the behavior after patching a user or removing a user
Benefits
isLoading
with a selector onisFinding || isGetting