I have a method that updates data within the component itself, for example:
Vue.component('component', {
template: '#component',
data: function () {
return {
dataToBeWatched: ''
}
},
methods: {
change: function (e) {
var that = this;
setTimeOut(function() {
that.dataToBeWatched = 'data changed';
}, 2000);
},
makeSmthWhenDataChanged: function () {
// Perform AJAX request when dataToBeWatched changes or is not empty
}
}
});
How can I create a watcher using correct methods in Vue.js? Should I use props to watch it within the component?