agraboso / agraboso/redux-api-middleware
Dispatch BAILOUT Event to Reducer when bailout function returns true.
- Dominant language
- JavaScript
- Stars
- 1.5k
- Forks
- 190
- PR merge metrics
- No merged PRs in 30d
Description
I currently have the following logic using this middleware.
`
state = {
items: { itemID: itemObj, .... },
viewingItemID: itemID,
}
`
**Case 1:**
'REQUEST' View Item> 'SUCCESS' Add new item to state -> Update viewingItemID to the item ID
OR
**Case 2:**
'REQUEST' View Item -> Bailout because View Item is already in the state (unable to update viewingItemID)
I then need to change the state's viewingItemID to the ID of the item the user would like to view .
However there is no action emitted to the reducer, so I cannot update the state after the bailout.
At the moment I get around this by dispatching actions 1: fetchItem, 2: setViewingItemID. However, this results in unnecessary state changes/react renders.
Would it be possible to add a bailout action that would be sent to the reducer?
Can I submit a pull request?
Contributor guide
Assessment
This issue has not been assessed yet.