O'Reilly logo

Mastering Angular Components by Gion Kunz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Pure components

The idea of a "pure" component is that its whole state is represented by its inputs, where all inputs are immutable. This is effectively a stateless component, but additionally, all the inputs are immutable.

I like to call such components "pure" because their behaviour can be compared to the concept of pure functions in functional programming. A pure function is a function which has the following properties:

  • It does not rely on any state outside of the function scope
  • It always behaves the same and returns the same result if input parameters don't change 
  • It never changes any state outside the function scope (side effect)

With pure components, we have a simple guarantee. A pure component will never change without its input ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required