stateMixin() — vue Function Reference
Architecture documentation for the stateMixin() function in state.ts from the vue codebase.
Entity Profile
Dependency Diagram
graph TD 35e04ef4_6742_973d_927e_07f7ffc64426["stateMixin()"] ba63994a_f426_3629_e039_acc8d1bcb187["createWatcher()"] 35e04ef4_6742_973d_927e_07f7ffc64426 -->|calls| ba63994a_f426_3629_e039_acc8d1bcb187 4a87a208_8bf5_28ff_be4d_8df11d928f69["pushTarget()"] 35e04ef4_6742_973d_927e_07f7ffc64426 -->|calls| 4a87a208_8bf5_28ff_be4d_8df11d928f69 f933dbd4_cb05_cc5c_162b_7ab5e35d316d["popTarget()"] 35e04ef4_6742_973d_927e_07f7ffc64426 -->|calls| f933dbd4_cb05_cc5c_162b_7ab5e35d316d 3d03878c_4a3a_4d94_b9f5_3c7287192b05["teardown()"] 35e04ef4_6742_973d_927e_07f7ffc64426 -->|calls| 3d03878c_4a3a_4d94_b9f5_3c7287192b05 style 35e04ef4_6742_973d_927e_07f7ffc64426 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
src/core/instance/state.ts lines 341–393
export function stateMixin(Vue: typeof Component) {
// flow somehow has problems with directly declared definition object
// when using Object.defineProperty, so we have to procedurally build up
// the object here.
const dataDef: any = {}
dataDef.get = function () {
return this._data
}
const propsDef: any = {}
propsDef.get = function () {
return this._props
}
if (__DEV__) {
dataDef.set = function () {
warn(
'Avoid replacing instance root $data. ' +
'Use nested data properties instead.',
this
)
}
propsDef.set = function () {
warn(`$props is readonly.`, this)
}
}
Object.defineProperty(Vue.prototype, '$data', dataDef)
Object.defineProperty(Vue.prototype, '$props', propsDef)
Vue.prototype.$set = set
Vue.prototype.$delete = del
Vue.prototype.$watch = function (
expOrFn: string | (() => any),
cb: any,
options?: Record<string, any>
): Function {
const vm: Component = this
if (isPlainObject(cb)) {
return createWatcher(vm, expOrFn, cb, options)
}
options = options || {}
options.user = true
const watcher = new Watcher(vm, expOrFn, cb, options)
if (options.immediate) {
const info = `callback for immediate watcher "${watcher.expression}"`
pushTarget()
invokeWithErrorHandling(cb, vm, [watcher.value], vm, info)
popTarget()
}
return function unwatchFn() {
watcher.teardown()
}
}
}
Domain
Subdomains
Source
Frequently Asked Questions
What does stateMixin() do?
stateMixin() is a function in the vue codebase.
What does stateMixin() call?
stateMixin() calls 4 function(s): createWatcher, popTarget, pushTarget, teardown.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free