Thursday, 3 September 2020

Why watcher is better than computed to perform asynchronous or expensive operations in response to changing data in vue.js?

Documentation of Vue.js says:

Using the watch option allows us to perform an asynchronous operation (accessing an API), limit how often we perform that operation, and set intermediary states until we get a final answer. None of that would be possible with a computed property.

While on the same page, we can see that computed property uses a function the same as watcher.

Reference: https://vuejs.org/v2/guide/computed.html#Computed-vs-Watched-Property

So my question is what is the technical reason supporting the above statement or limiting us from using computed properties instead of watchers?



from Why watcher is better than computed to perform asynchronous or expensive operations in response to changing data in vue.js?

No comments:

Post a Comment