04. Computed Properties and Watchers Flashcards
Computed Properties
computed properties are cached based on their dependencies.
A computed property will only re-evaluate when some of its dependencies have changed.
Direferencia entre Propiedades Computadas y Métodos
the difference is that computed properties are cached based on their dependencies.
In comparison, a method invocation will always run the function whenever a re-render happens
Why do we need caching?
Why do we need caching? Imagine we have an expensive computed property A, which requires looping through a huge Array and doing a lot of computations. Then we may have other computed properties that in turn depend on A. Without caching, we would be executing A’s getter many more times than necessary! In cases where you do not want caching, use a method instead.