Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 | 1x 1x 2x 11x 10x 1x 1x 1x | export function initWatch (vm, watch) { return Object.keys(watch).reduce((acc, key) => ({ ...acc, [key]: function defineWatch (newVal) { if (!this.$component || !this.$component._isMounted) { return } // Always equal to the newVal const oldVal = this.data[key] const handler = Array.isArray(watch[key]) ? watch[key] : [ watch[key] ] handler.forEach(h => { this[h.handler](newVal, oldVal) }) } }), {}) } |