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 filtering callbacks #11

Open
robertpainsi opened this issue May 14, 2023 · 2 comments
Open

Add filtering callbacks #11

robertpainsi opened this issue May 14, 2023 · 2 comments
Milestone

Comments

@robertpainsi
Copy link
Owner

robertpainsi commented May 14, 2023

Add new filtering callbacks

  • beforeFilter
    • Called before actually executing the filter logic. Returning false should abort filtering and not further callbacks should be called.
  • filterItem
    • Called for each item. Returning a truthy value will consider the item in the filtering process and add it to the Result.allItems. This can be useful if you want to add custom filtering logic, like if you also filter by the title of the item.
  • filter
  • afterFilter
    • Called after executing the filter logic.
@robertpainsi robertpainsi modified the milestone: 1.0.0 May 14, 2023
@robertpainsi
Copy link
Owner Author

For now only filterItem will be implemented. It's the only callback which users can't implement themselves. All others can easily be implemented without callbacks. However, other callbacks will be added after version 1.0.0.

robertpainsi added a commit that referenced this issue May 14, 2023
When returning a truthy value in the `filterItem` callback, the item
will be considered for filtering. The callback is called for each item
and also for each call of `filter`.
robertpainsi added a commit that referenced this issue May 15, 2023
There is no need to return a Promise for filter. Additional callbacks
mentioned in #11 will help easeing DX.
@robertpainsi robertpainsi added this to the 1.0.0 milestone May 18, 2023
@robertpainsi robertpainsi modified the milestones: 1.0.0, 2.0.0 May 18, 2023
@robertpainsi
Copy link
Owner Author

Using the library in real case scenarios, more before and after callbacks are needed to simplify using the library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant