Choosing actions for reducer with regexp
See original GitHub issueNormally you write something like:
[SOME_ACTION_TYPE]: someActionTypeHandler,
So it picks a specific action type and handles it with specific reducer.
I’d like to be able to “catch” action types with regexp. For example, I want to handle every action type that ends with _DONE
with a specific successReducer
.
Don’t see a way to do that with the current API. Should we implement something to enable such usecase?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:4
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Redux Fundamentals, Part 3: State, Actions, and Reducers
Reducers are functions that take the current state and an action as arguments, and return a new state result. In other words, (state,...
Read more >Redux can reducer accept multiple actions - Stack Overflow
There are always a couple of different ways that you can create you actions, action reducers etc. However the most important thing to ......
Read more >RegExp: Match, Search, Replace and Split Like a Master
In this post, I want to show you the beauty of regular expressions. Develop a Zen mind. RegEx is one of those 'things'...
Read more >Building out Redux store / actions / reducers -- strategies?
Do you brainstorm a list of all possible actions, or take your database tree ... value: '' }], // array of react-select objects...
Read more >Where do I put my business logic in a React Redux application?
Choosing where to put your business logic is an important decision. ... fat action creators; reducers; thunks; sagas - redux-saga; epics - redux-observable ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Why not compose the
redux-actions
reducer? Something like this:You could easily extract this into a helper method and use it across your app. I’m reticent to add support for regular expression matching since it introduces quite a bit of complexity. What happens when both a regex and string key match? How do we store references to the passed-in regexes, since JS objects can only support string keys? If we’re supporting regexes, why not arbitrary functions?
Yes, but I’m looking for a more generic solution…
27.9.2017 23.59 “Victor Alvarez” notifications@github.com kirjoitti: