DEV Community

loading...

Discussion on: Introduction to Vue Watchers

Collapse
kennyrafael profile image
kennyrafael • Edited

Would be nice to add immediate: true. This way you can do something like this:

selectedAuthor: {
      handler: 'fetchPosts',
      immediate: true
},
data: function () {
      selectedAuthor: 0,
      authors: [...]
}
Enter fullscreen mode Exit fullscreen mode

immediate: true means your handler will trigger when the component is mounted, and again when the property changes.

Collapse
lindaojo profile image