From 3de774e778b4619050ce1dc407c53caeed8b6c92 Mon Sep 17 00:00:00 2001 From: David Shevitz Date: Wed, 26 May 2021 21:04:12 +0000 Subject: [PATCH] docs: add guidance on adding filtering and sorting logic to componetns instead of pipes (#42368) Fixes #41652 PR Close #42368 --- aio/content/guide/styleguide.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/aio/content/guide/styleguide.md b/aio/content/guide/styleguide.md index 36f08420f4..d2c53bdf4f 100644 --- a/aio/content/guide/styleguide.md +++ b/aio/content/guide/styleguide.md @@ -2759,6 +2759,30 @@ A typical *lazy loaded folder* contains a *routing component*, its child compone Back to top +### Do not add filtering and sorting logic to pipes + +#### Style 04-13 + +
+ +**Avoid** adding filtering or sorting logic into custom pipes. + +
+ +
+ +**Do** pre-compute the filtering and sorting logic in components or services before binding the model in templates. + +
+ +
+ +**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. + +
+ +Back to top + ## Components {@a 05-03}