Closed mattkrick closed 8 years ago
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 master
is slightly changed as I now pass the whole action object to the whitelist function (see cbe98031ffea10b6ab882f840cd5e900c46473c4).
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.