With Vue 2, developers were reliant on the Options API to build single-file components, which enforced a level of structure to how the system was used.
The Composition API, on the other hand, gives the developer new opportunities to build reactive applications.
In a previous article, we explored the difference between ref and reactive methods.
Let's build on that understanding, and introduce two new methods from the Composition API - watch and watchEffect.
The Options API provided us with the watch option, which is a way to observe when values changed and perform side effects based on that.
Let's summarize what's going on here:. In our template, we have a textarea that is bound to our data value of notes.
For further reading on watchers with the Options API, here's a link to the documentation for Vue 2.
- Now that we have a basic understanding of watchers in the Options API, let's dive into the Composition API!
- The Composition API provides us with two different methods to handle side effects - watch and watchEffect.