Search code examples
angularangular-pipe

Purpose of using impure pipe in Angular


What is purpose of impure pipes in Angular? If we use immutable approach and use objects as input values, the pure pipe will change output, and at the same time it will not be called on each change detection, as the impure pipe. Then, some state properties (as cache) we can use in impure and in pure pipe together.

Can you tell me the purpose of impure pipes?


Solution

  • the async pipe is a good example. You are passing an Observable in as the input of the async pipe, which is probably not going to be changing its instance of Observable, so we would want the async pipe to update its output more often then the instance changing.