Created
February 20, 2017 13:35
-
-
Save npras/df1d3390a75c1d66185d5cf466808696 to your computer and use it in GitHub Desktop.
VueJS - Implementing Computed Property - Part Two
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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