How to use the watch function from vue

Find comprehensive JavaScript vue.watch code examples handpicked from public code repositorys.

79
80
81
82
83
84
85
86
87
88
  style.msTransform = transform;
  style.webkitTransform = transform;
  return style;
};
const barStyle = vue.ref(getBarStyle());
vue.watch(() => props.tabs, () => {
  vue.nextTick(() => {
    barStyle.value = getBarStyle();
  });
});
fork icon3
star icon8
watch icon3

+ 3 other calls in file

255
256
257
258
259
260
261
262
263
264
    this.setAutomaticClose();
    this.commit('isOpen', false);
    this.buildAllOptions(true);
    this.buildSelectedOptions();
}, { deep: true });
vue.watch(() => [this.listOptions, this.elementOptions], () => {
    /* TODO: transform allOptions as a computed properties and this
     * watcher become useless */
    this.buildAllOptions(true);
}, { deep: true });
fork icon1
star icon7
watch icon6

+ 242 other calls in file

106
107
108
109
110
111
112
113
114
115
    states.visible = regexp.test(currentLabel.value) || props.created;
    if (!states.visible) {
        select.filteredOptionsCount--;
    }
};
vue.watch(() => currentLabel.value, () => {
    if (!props.created && !select.props.remote)
        select.setSelected();
});
vue.watch(() => props.value, (val, oldVal) => {
fork icon1
star icon2
watch icon1

+ 5 other calls in file

195
196
197
198
199
200
201
202
203
204
    }
    yield vue.nextTick();
    initData.dragging && displayTooltip();
    tooltip.value.updatePopper();
});
vue.watch(() => initData.dragging, val => {
    updateDragging(val);
});
return {
    tooltip,
fork icon1
star icon2
watch icon1

29
30
31
32
33
34
35
36
37
38
const lineStyle = vue.ref({});
const internalStatus = vue.ref('');
const parent = vue.inject('ElSteps');
const currentInstance = vue.getCurrentInstance();
vue.onMounted(() => {
    vue.watch([() => parent.props.active, () => parent.props.processStatus, () => parent.props.finishStatus], ([active]) => {
        updateStatus(active);
    }, { immediate: true });
});
vue.onBeforeUnmount(() => {
fork icon1
star icon2
watch icon1

18
19
20
21
22
23
24
25
26
27
const isVertical = vue.ref(true);
const sizeKey = vue.ref('');
const scrollKey = vue.ref('');
const translateKey = vue.ref();
const styleKey = vue.ref('');
vue.watch(() => props.direction, dir => {
    const _isVertical = dir === 'v';
    isVertical.value = _isVertical;
    sizeKey.value = `client${_isVertical ? 'Height' : 'Width'}`;
    scrollKey.value = `scroll${_isVertical ? 'Top' : 'Left'}`;
fork icon1
star icon2
watch icon1

+ 3 other calls in file

42
43
44
45
46
47
48
49
50
51
setup(props, { slots }) {
    const el = vue.ref(null);
    const elForm = vue.inject(elFormKey);
    const elFormItem = vue.inject(elFormItemKey);
    const computedWidth = vue.ref(0);
    vue.watch(computedWidth, (val, oldVal) => {
        if (props.updateAll) {
            elForm.registerLabelWidth(val, oldVal);
            elFormItem.updateComputedLabelWidth(val);
        }
fork icon1
star icon2
watch icon1

+ 5 other calls in file

98
99
100
101
102
103
104
105
106
107

_vue.onMounted(() => {
  _changeSelect();
});

_vue.watch(() => route.name, _changeSelect);

_vue.watch(() => collapsed.value, newCollapsed => {
  if (!newCollapsed) {
    const matched = [..._vue.toRaw(route.meta.breadcrumb || [])];
fork icon1
star icon1
watch icon4

+ 7 other calls in file

318
319
320
321
322
323
324
325
326
327
    return {
        gap: convertToUnit(props.tabGap),
    };
});
// -------------------------------------------------- Watch //
vue.watch(props, () => {
    if (props.theme) {
        useTheme.value = props.theme;
        loadTheme();
    }
fork icon0
star icon1
watch icon1

1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
    var this$1$1 = this;


  if ((process.env.NODE_ENV !== 'production')) {
    assert(typeof getter === 'function', "store.watch only accepts a function.");
  }
  return vue.watch(function () { return getter(this$1$1.state, this$1$1.getters); }, cb, Object.assign({}, options))
};


Store.prototype.replaceState = function replaceState (state) {
    var this$1$1 = this;
fork icon0
star icon0
watch icon1

+ 43 other calls in file

341
342
343
344
345
346
347
348
349
350
351
    )
  }
}


function enableStrictMode (store) {
  vue.watch(function () { return store._state.data }, function () {
    if ((process.env.NODE_ENV !== 'production')) {
      assert(store._committing, 'do not mutate vuex store state outside mutation handlers.')
    }
  }, { deep: true, flush: 'sync' })
fork icon0
star icon0
watch icon1

+ 7 other calls in file

86
87
88
89
90
91
92
93
94
95
    element.value.style.visibility = ''
  }
  TinyMCE_1.getTinymce().init(finalInit)
  mounting = false
}
vue_1.watch(disabled, function (disable) {
  if (vueEditor !== null) {
    vueEditor.setMode(disable ? 'readonly' : 'design')
  }
})
fork icon0
star icon0
watch icon1

108
109
110
111
112
113
114
115
116
117
}
exports.bindHandlers = bindHandlers
var bindModelHandlers = function (props, ctx, editor, modelValue) {
  var modelEvents = props.modelEvents ? props.modelEvents : null
  var normalizedEvents = Array.isArray(modelEvents) ? modelEvents.join(' ') : modelEvents
  vue_1.watch(modelValue, function (val, prevVal) {
    if (
      editor &&
      typeof val === 'string' &&
      val !== prevVal &&
fork icon0
star icon0
watch icon1

2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
vue.provide(matchedRouteKey, matchedRouteRef);
vue.provide(routerViewLocationKey, routeToDisplay);
const viewRef = vue.ref();
// watch at the same time the component instance, the route record we are
// rendering, and the name
vue.watch(() => [viewRef.value, matchedRouteRef.value, props.name], ([instance, to, name], [oldInstance, from, oldName]) => {
    // copy reused instances
    if (to) {
        // this will update the instance for new instances as well as reused
        // instances when navigating to a new route
fork icon0
star icon0
watch icon1

+ 23 other calls in file

742
743
744
745
746
747
748
749
750
751
}
if (!manager) {
    throw new Error('No manager or current instance');
}
if (vue.isProxy(source)) {
    vue.watch(source, (newSource, oldSource) => {
        applyDifference(metaProxy.meta, newSource, oldSource);
    });
    source = source.value;
}
fork icon0
star icon0
watch icon1

+ 3 other calls in file