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

Combine filters #71

Closed
peteruithoven opened this issue Mar 24, 2016 · 5 comments
Closed

Combine filters #71

peteruithoven opened this issue Mar 24, 2016 · 5 comments
Labels
help wanted Help needed from the open source community helper function
Milestone

Comments

@peteruithoven
Copy link
Collaborator

Is there an easy way to combine multiple filter functions together?
I noticed I was writing one function which performed 3 filters and I couldn't easily combine the existing helper filter functions. What if we create a combine function, something like below, that checks all filters:

undoable(reducer, { filter: combineFilters(distinctState(), excludeAction(SOME_ACTION)) });

This, for edge cases, also allows usage inside a custom undoFilter:

undoable(reducer, { filter: undoFilter });
function undoFilter(action, currentState, previousState) {
  let filter = combineFilters(distinctState(), excludeAction(SOME_ACTION))(action, currentState, previousState);
  if(!filter) return filter; 
  // more filters
}
@omnidan
Copy link
Owner

omnidan commented Mar 24, 2016

@peteruithoven you're right, this is not currently possible. However, on the latest release beta4, there is no need for distinctState() anymore. Might be interesting as a helper though.

@omnidan omnidan added this to the 1.0-beta5 milestone Mar 24, 2016
@omnidan omnidan added the help wanted Help needed from the open source community label Mar 24, 2016
@peteruithoven
Copy link
Collaborator Author

It's mostly for when you want to combine filters for exclusion and different throttling techniques for example. I'll try to work on a pull request.

@Bear-Foot
Copy link
Contributor

Hello there. @peteruithoven are you up to something about this ? I'd be glad to help if you are too busy.

@peteruithoven
Copy link
Collaborator Author

I'm afraid I haven't come around to it yet, I got stuck at figuring out how the unit tests worked. But through Gitter I did see your gist and omnidan's fork, nice work!

teameh added a commit that referenced this issue Apr 12, 2016
Adding combineFilters(), docs and tests for #71
@omnidan
Copy link
Owner

omnidan commented Apr 15, 2016

Resolved in beta7

@omnidan omnidan closed this as completed Apr 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Help needed from the open source community helper function
Projects
None yet
Development

No branches or pull requests

3 participants