allow whitelist to be a function #148
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MichaelContento/redux-storage!148
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "master"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
A pretty standard practice is for 3rd party reducers to use a prefix for all of their actions (eg
redux-form/DESTROY). In my use case, I'd like to disallow every action triggered by a certain 3rd party reducer (eg every action that begins withredux-form/) .Today, I'd have to know & list every single action that a 3rd party reducer can create. That's a long list. Plus, I run the risk of the list going stale when my 3rd party package updates or changes a constant.
I can accomplish what I want by iterating over the entire blacklist & checking to see if my blacklisted substring is found in each entry. However, your logic may differ.
That's why if we allow the whitelist to be a function, everyone wins. For example, I'd write something like this:
And you can use whatever logic you like.
The idea is borrowed from webpack, where a bunch of config fields can either be an array or a function.
Also, this maintains backwards compatibility, so no breaking changes
@michaelcontento any thoughts? feedback?
Sorry for the late response! 😞
I'll have a look tomorrow and, after a very quick review, it looks awesome! 🚀 👍
Thank you very much 🎉
sounds great! here's another example of using it in the wild:
https://github.com/ParabolInc/action/blob/master/src/client/makeStore.js#L10-L19
🐻 👈
Merged but the behaviour in
masteris slightly changed as I now pass the whole action object to the whitelist function (seecbe98031ff).