Skip to content

Commit

Permalink
fix(ui): sharedData watchers
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Chau committed Jun 13, 2018
1 parent 2239e56 commit f486d7e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/@vue/cli-ui/src/util/shared-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ export default {
}
},

beforeCreate () {
Object.defineProperty(this, '$sharedData', {
get: () => this.$data.$sharedData,
enumerable: true,
configurable: true
})
},

created () {
const options = this.$options.sharedData
if (options) {
Expand All @@ -48,6 +56,11 @@ export default {
} else {
this.$syncSharedData(options)
}
// Force watchers to re-evaluate
// Because we just added the proxies to this.$data.$sharedData[key]
this._watchers.forEach(watcher => {
watcher.update()
})
}
},

Expand Down

0 comments on commit f486d7e

Please sign in to comment.