Angular impure pipe

Publicado em: 09 Maio 2018
no canal de: kudvenkat
24,770
169

In this video we will discuss impure pipes and their performance implications.

Healthy diet is very important for both body and mind. We want to inspire you to cook and eat healthy. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking.
   / @aarvikitchen5572  

Text version of the video
http://csharp-video-tutorials.blogspo...

Slides
http://csharp-video-tutorials.blogspo...

Angular CRUD Tutorial
   • Angular CRUD tutorial  

Angular CRUD Tutorial Text Articles & Slides
http://csharp-video-tutorials.blogspo...

All Dot Net and SQL Server Tutorials in English
https://www.youtube.com/user/kudvenka...

All Dot Net and SQL Server Tutorials in Arabic
   / kudvenkatarabic  

This is continuation to Part 48, please watch Part 48 from Angular CRUD tutorial before proceeding.

In our previous 2 videos we implemented a pure pipe to filter employee data. A pure pipe is only executed when a pure change to the input value is detected.

Pure pipes are fast, but using them for filtering data is not a good idea because, the filtering may not work as expected if the source data is updated without a change to the object reference.

One way to make this work is by making the pipe impure. Impure pipes can significantly impact the performance of the application as they run on every change detection cycle. To make a pipe impure, set it's pure property to false.

@Pipe({
name: 'employeeFilter',
pure: false
})
export class EmployeeFilterPipe implements PipeTransform {

You have to think very carefully when you make a pipe impure. This is because an impure pipe is processed on every change, even when the source data does not change. They run unnecessarily when not required.

If you have an array with thousands of objects and each object in turn has dozens of properties. Now if we use an impure pipe to filter or sort this array and for some reason on the same page if we are also listening to the mosue move or keystroke event, then the pipe is unnecessarily executed for every mouse move or keystroke which can significantly degrade the performance of the application.

This is the reason, Angular team recommends not to use pipes to filter and sort data. Angular recommends to move the filtering and sorting logic into the component itself. We will discuss how to implement filtering in a component in our next video.


Nesta página do site você pode assistir ao vídeo on-line Angular impure pipe duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário kudvenkat 09 Maio 2018, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 24,770 vezes e gostou 169 espectadores. Boa visualização!