Skip to content

Commit ea32072

Browse files
committed
simplifying vue.Watch
1 parent 3b681cf commit ea32072

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

vue.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ type Vue struct {
119119
// immdediate Boolean optional
120120
// Watch an expression on the Vue instance for changes.
121121
// The expression can be a single keypath or actual expressions:
122-
Watch func(
122+
WatchEx func(
123123
expression string,
124124
callback func(newVal, oldVal *js.Object),
125125
deepWatch bool,
@@ -316,6 +316,13 @@ type Vue struct {
316316
// vm.$log() // logs entire ViewModel data
317317
// vm.$log('item') // logs vm.item
318318
Log func(keypath ...interface{}) `js:"$log"`
319+
320+
// Defer the callback to be executed after the next DOM update cycle.
321+
// Use it immediately after you’ve changed some data to
322+
// wait for the DOM update. This is the same as the global
323+
// Vue.nextTick, except that the callback’s this context is
324+
// automatically bound to the instance calling this method.
325+
NextTick func(cb func()) `js:"$nextTick"`
319326
}
320327

321328
// New creates a VueJS Instance to apply bidings between `structPtr` and
@@ -377,7 +384,7 @@ func GetVM(structPtr interface{}) *Vue {
377384
}
378385

379386
// WatchEx using a simpler form to do Vue.$watch
380-
func (v *Vue) WatchEx(expression string, callback func(newVal *js.Object)) (unwatcher func()) {
387+
func (v *Vue) Watch(expression string, callback func(newVal *js.Object)) (unwatcher func()) {
381388
obj := v.Call("$watch", expression, callback)
382389
return func() {
383390
obj.Invoke()

0 commit comments

Comments
 (0)