Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add actionsBlacklist and actionsWhitelist config options #79

Conversation

evgenykochetkov
Copy link
Contributor

I think it is much more convenient to set these options in window.devToolsExtension() config.

@zalmoxisus
Copy link
Owner

Hey @evgenykochetkov,

Thanks for the contribution! I like the implementation and agree about the convenience of setting it directly in the code for each project individually. The problem here is that every time we have something changed in the settings, we inject new window.devToolsOptions to apply the changes without reloading the page (that's why we expose this object globally). So, we probably should use a local object (let's say localFilter) for this case not to have it overwritten. And then implement filtering like this:

  function isFiltered(action) {
    if (!localFilter && !window.devToolsOptions.filter) return false;
    const { whitelist, blacklist } = localFilter || window.devToolsOptions;
    return (
      whitelist && !action.type.match(whitelist) ||
      blacklist && action.type.match(blacklist)
    );
  }

  function addFilter(state) {
    if (localFilter || window.devToolsOptions.filter) {
      const { whitelist, blacklist } = localFilter || window.devToolsOptions;
      if (whitelist) state.whitelist = [whitelist];
      else if (blacklist) state.blacklist = [blacklist];
    }
  }

@evgenykochetkov
Copy link
Contributor Author

Thanks for the explanation! I corrected the implementation.

P.S:
This line is beautiful😍 const { whitelist, blacklist } = localFilter || window.devToolsOptions;

@zalmoxisus zalmoxisus merged commit 5e6337f into zalmoxisus:master Mar 26, 2016
@zalmoxisus
Copy link
Owner

Thanks a lot for the fixes!

Yes, boolean operators are awesome along with ES6. :-)
Also, for example, instead of

const actionsArrToReg = (arr) => arr ? arr.join('|') : null;

it could be

const actionsArrToReg = (arr) => arr && arr.join('|');

It's not better or worse, just different styles, though we could not use the function at all in this case.

@zalmoxisus zalmoxisus mentioned this pull request Mar 28, 2016
HadesHappy added a commit to HadesHappy/redux-devtools-extension that referenced this pull request Aug 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants