@@ -51,12 +51,20 @@ function isValidAction(action) {
5151 return false ;
5252}
5353
54+ function handleWhitelist ( action , actionWhitelist ) {
55+ if ( Array . isArray ( actionWhitelist ) ) {
56+ // Don't filter if the whitelist is empty
57+ return actionWhitelist . length === 0 ? true : actionWhitelist . indexOf ( action . type ) !== - 1 ;
58+ }
59+ // actionWhitelist is a function that returns true or false
60+ return actionWhitelist ( action . type ) ;
61+ }
5462
5563export default ( engine , actionBlacklist = [ ] , actionWhitelist = [ ] ) => {
5664 // Also don't save if we process our own actions
5765 const blacklistedActions = [ ...actionBlacklist , LOAD , SAVE ] ;
5866
59- if ( process . env . NODE_ENV !== 'production' ) {
67+ if ( process . env . NODE_ENV !== 'production' && Array . isArray ( actionWhitelist ) ) {
6068 warnAboutConfusingFiltering ( actionBlacklist , actionWhitelist ) ;
6169 }
6270
@@ -69,9 +77,7 @@ export default (engine, actionBlacklist = [], actionWhitelist = []) => {
6977 }
7078
7179 const isOnBlacklist = blacklistedActions . indexOf ( action . type ) !== - 1 ;
72- const isOnWhitelist = actionWhitelist . length === 0
73- ? true // Don't filter if the whitelist is empty
74- : actionWhitelist . indexOf ( action . type ) !== - 1 ;
80+ const isOnWhitelist = handleWhitelist ( action , actionWhitelist ) ;
7581
7682 // Skip blacklisted actions
7783 if ( ! isOnBlacklist && isOnWhitelist ) {
0 commit comments