-
Notifications
You must be signed in to change notification settings - Fork 12
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
Handler map factory should handle optimistic action type #4
Labels
enhancement
New feature or request
good first issue
Good for newcomers
help wanted
Extra attention is needed
Comments
Also in many cases |
A solution for shared logic is to handle cancel and error separately: createHandlerMap(addFoo, {
next(state, action) {},
complete(state, action) {},
})
createHandlerMap([addFoo.error, addFoo.cancel], (state, action) => { /* shared logic */ }) |
Hey @thebrodmann again! |
Just by using const addFoo = {
next: createActionCreator('NEXT'),
error: createActionCreator('ERROR'),
cancel: createActionCreator('CANCEL'),
complete: createActionCreator('COMPLETE'),
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
enhancement
New feature or request
good first issue
Good for newcomers
help wanted
Extra attention is needed
According to #2,
createHandlerMap
should be capable to handle optimistic action creators.Detailed Description
Yet, optimistic actions should be handled separately with multiple
createHandlerMap
call. So there would be a good point to reduce boilerplates.Although, cancel is not part of observer protocol but this type practically is important and should be handled in many cases (isFetching entity, etc.) in the reducers.
Possible Implementation
The text was updated successfully, but these errors were encountered: