Skip to content

Instantly share code, notes, and snippets.

@npras
Created February 20, 2017 13:35
Show Gist options
  • Save npras/df1d3390a75c1d66185d5cf466808696 to your computer and use it in GitHub Desktop.
Save npras/df1d3390a75c1d66185d5cf466808696 to your computer and use it in GitHub Desktop.
VueJS - Implementing Computed Property - Part Two
class Watcher {
constructor(vm, valueFn) {
this.vm = vm;
this.getter = valueFn;
this.value = this.get();
}
get() {
let value;
const vm = this.vm;
value = this.getter.call(vm);
return value;
}
}
module.exports = Watcher;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment