In directive bind method, there is a vnode.context.$watch
and every time that directive added to HTML, it is also adding another watcher with previous watcher. Because of that same watchers are calling more than once.
Is there any way to destroy the previous watcher when directive unbind method called.
Vue.directive("dynamic-lookup", {
bind: function (el, binding, vnode) {
let dependency = setValue("dynamic-lookup-dependency");
if (dependency) {
vnode.context.$watch(dependency, function (newVal, oldVal) { }); });
}
},
unbind: function(el, binding, vnode) {
console.log("unbind");
}
});