Rules
"Rules" are static definitions that tell Finder how to interact with the unique shape of your Items objects. Finder will use that information to determine what internal state to track.
Each category of rules has a corresponding api to access and mutate their state.
| Rule | API | Purpose |
|---|---|---|
| SearchRule | finder.search | Determine which properties in your Item should be searchable. |
| FilterRule | finder.filter | Determine what filter predicates are required, and how they should be tested against your Items. |
| SortByRule | finder.sortBy | Determine what order your Items should be displayed in. |
| GroupByRule | finder.groupBy | Determine how to categorize your Items |
Rule Processing Order
-
During the Identify Matches phase, items are tested against all active Search and Filter rules. Any mismatches are discarded.
-
In Sort and Slice Matches, surviving items are ordered and paginated. This phase is skipped if no SortBy rules are active and pagination is not enabled.
-
Lastly, we Group Matches if a GroupBy rule is active. The searched + filtered + sorted + paginated items array is grouped by a common property defined in the GroupBy rule.