docs: add guidance on adding filtering and sorting logic to componetns instead of pipes (#42368)

Fixes #41652

PR Close #42368
This commit is contained in:
David Shevitz 2021-05-26 21:04:12 +00:00 committed by Jessica Janiuk
parent e1a80d4b24
commit 3de774e778
1 changed files with 24 additions and 0 deletions

View File

@ -2759,6 +2759,30 @@ A typical *lazy loaded folder* contains a *routing component*, its child compone
<a href="#toc">Back to top</a>
### Do not add filtering and sorting logic to pipes
#### Style 04-13
<div class="s-rule avoid">
**Avoid** adding filtering or sorting logic into custom pipes.
</div>
<div class="s-rule do">
**Do** pre-compute the filtering and sorting logic in components or services before binding the model in templates.
</div>
<div class="s-why-last">
**Why?** Filtering and especially sorting are expensive operations. As Angular can call pipe methods many times per second, sorting and filtering operations can degrade the user experience severely for even moderately-sized lists.
</div>
<a href="#toc">Back to top</a>
## Components
{@a 05-03}