Skip to content

Instantly share code, notes, and snippets.

@superMDguy
Last active September 27, 2017 23:08
Show Gist options
  • Save superMDguy/a4726f25b799aeecbb696a58a47299f6 to your computer and use it in GitHub Desktop.
Save superMDguy/a4726f25b799aeecbb696a58a47299f6 to your computer and use it in GitHub Desktop.
const data = {
name: 'World',
feeling: 'like'
}
walk(data) // adds reactivity to the data object
new Watcher(
() => `Hello, ${data.name}. I ${data.feeling} Vue.js.`, // the value getter we're watching
(val, oldVal) => console.log(val) // the callback, fired on changes to dependencies of the value getter
) // logs 'Hello, World. I like Vue.js'
data.name = 'Universe' // logs 'Hello, Universe. I like Vue.js'
data.feeling = 'love' // logs 'Hello, Universe. I love Vue.js'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment