Developing stateful pipes
There is one common thing among all the pipes mentioned earlier—all of them return exactly the same result each time we apply them to the same value and pass them the same set of arguments. Such pipes, which hold the referentially transparency property, are called pure pipes.
The @Pipe decorator accepts an object literal of the { name: string, pure?: boolean } type, where the default value for the pure property is true. This means that when we define any given pipe, we can declare whether it is stateful or stateless. The pure property is important because, in case the pipe doesn't produce side effects and returns the same result when applied to the same set of arguments, the change detection can be optimized.
Now, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access