Skip to content
This repository has been archived by the owner on Feb 22, 2018. It is now read-only.

Filter chaining: does order of filters matter? #74

Closed
zoechi opened this issue Feb 10, 2014 · 3 comments
Closed

Filter chaining: does order of filters matter? #74

zoechi opened this issue Feb 10, 2014 · 3 comments

Comments

@zoechi
Copy link

zoechi commented Feb 10, 2014

https://angulardart.org/tutorial/07-ch05-filter-service.html

The example indicates that the filters are evaluated from right to left but it's not stated explicitely. It could also be left to right (would lead to the same result but probably less efficient).
A brief explanation would be helpful.

@kkruups
Copy link

kkruups commented Aug 20, 2014

Hi Zoechi,

It looks like Filter Chaining would definitely matter, depending on where the filter is placed would change behavior. I agree the tutorial glosses over, formatters, not enough detail to know how they work. It is not clear how the filter order is evaluated, however below is my pseudo mapping of I think it works IMHO. I agree it must be from right to left. It would be nice to get a deeper understanding of how this black magic works.

Chain of Execution for Evaluating filters in ng-repeat

Formatters/Filters gain access to list inside repeaters, such as ng-repeat

recipeList is provided via ng-repeat's scope to cf

cf=categoryfilter(list, map<category, isChecked>) --> categorizedList

fltr=filter (list, nameFilterString)--> filteredList, name

ordBy=orderBy(list, name)--> orderdList

1.First get categories selected by user, pass list to next filter
2. Filter on Inputted text with dependency on categories selected
3.Order the list which was Filtered in 2 above base on default ascending order by name
4. create a html span for each item in list
Html View (from right to left: 1., 2., 3., 4. as indicated below):

<span 4.ng-repeat=recipe in ordererdList | <==3.ordBy(fltr) | <== 2.fltr(cf, nameFilterstring) | <==1.cf(recipeList , map<category, isChecked) />

@kkruups
Copy link

kkruups commented Aug 20, 2014

Did not all fit in Comment Above (here is missing text):

Html View (from right to left: 1., 2., 3., 4. as indicated below):

< 4.ng-repeat=recipe in ordererdList | <==3.ordBy(fltr) | <== 2.fltr(cf, nameFilterstring) | <== 1. cf(recipeList , map < category, isChecked > ) >

  <span tooltip="ctrl.tooltipForRecipe(recipe)">
          <rating max-rating="5" rating="recipe.rating"></rating>
          <span class="extra-space"
                ng-click="ctrl.selectRecipe(recipe)">{{recipe.name}}</span>
 </span>

< / >

@kkruups
Copy link

kkruups commented Sep 2, 2014

For complete discussion on this topic view stack overflow reference below:

http://stackoverflow.com/questions/25398707/angulardart-filter-chaining-does-order-of-filters-matter

@zoechi zoechi closed this as completed Mar 1, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants