Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Optimization: "pure" filters #697

Closed
kseamon opened this issue Dec 19, 2011 · 4 comments
Closed

Optimization: "pure" filters #697

kseamon opened this issue Dec 19, 2011 · 4 comments

Comments

@kseamon
Copy link
Contributor

kseamon commented Dec 19, 2011

Currently (as of 10.6), filters in expressions in a template are called on every $watch iteration.

It would speed things up if we could declare a filter as pure (ie, for a given input the same output will always be produced) so that these calls could be removed from the $watch (just watch the input instead).

@IgorMinar
Copy link
Contributor

We discussed this with Vojta and both of us agree that this would be a great feature to have.

It requires some significant changes to $parse, $watch and filter api, but it's doable.

In the mean time caching/memoizing filters is the best workaround.

@ProLoser
Copy link
Contributor

I had an issue where a coworker was filtering out html before it's insertion into a textarea for use in a wysiwyg. However every time the user edits in the wysiwyg and the textarea is updated, the refresh would cause the filter to re-fire and screw up the wysiwyg. This is like, every couple of key presses, and WYSIWYGs don't need filtering (usually) as they handle it themselves.

If you're still with me, I told him that we should be filtering the data when it's retrieved (in the model/service layer), as the business logic should be responsible for validating/sanitizing/normalizing it before it is spread out and used across the app. This is my general design approach. Perhaps look towards relocating your logic to when the data is retrieved?

@pkozlowski-opensource
Copy link
Member

Another report of the same: #1149

@btford
Copy link
Contributor

btford commented Aug 24, 2013

As part of our effort to clean out old issues, this issue is being automatically closed since it has been inactivite for over two months.

Please try the newest versions of Angular (1.0.8 and 1.2.0-rc.1), and if the issue persists, comment below so we can discuss it.

Thanks!

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

No branches or pull requests

5 participants