constructor() — vue Function Reference
Architecture documentation for the constructor() function in watcher.ts from the vue codebase.
Entity Profile
Dependency Diagram
graph TD 8603c200_e0a7_36c4_e293_fa045d31fa46["constructor()"] e7f4f452_deed_8a48_b501_c415a06a6251["Watcher"] 8603c200_e0a7_36c4_e293_fa045d31fa46 -->|defined in| e7f4f452_deed_8a48_b501_c415a06a6251 ad67e7ed_c155_de53_2de2_0458d2c842ef["get()"] 8603c200_e0a7_36c4_e293_fa045d31fa46 -->|calls| ad67e7ed_c155_de53_2de2_0458d2c842ef f85018be_e0a0_2003_eea0_3ff58670fc4b["constructor()"] 8603c200_e0a7_36c4_e293_fa045d31fa46 -->|calls| f85018be_e0a0_2003_eea0_3ff58670fc4b style 8603c200_e0a7_36c4_e293_fa045d31fa46 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
src/core/observer/watcher.ts lines 67–128
constructor(
vm: Component | null,
expOrFn: string | (() => any),
cb: Function,
options?: WatcherOptions | null,
isRenderWatcher?: boolean
) {
recordEffectScope(
this,
// if the active effect scope is manually created (not a component scope),
// prioritize it
activeEffectScope && !activeEffectScope._vm
? activeEffectScope
: vm
? vm._scope
: undefined
)
if ((this.vm = vm) && isRenderWatcher) {
vm._watcher = this
}
// options
if (options) {
this.deep = !!options.deep
this.user = !!options.user
this.lazy = !!options.lazy
this.sync = !!options.sync
this.before = options.before
if (__DEV__) {
this.onTrack = options.onTrack
this.onTrigger = options.onTrigger
}
} else {
this.deep = this.user = this.lazy = this.sync = false
}
this.cb = cb
this.id = ++uid // uid for batching
this.active = true
this.post = false
this.dirty = this.lazy // for lazy watchers
this.deps = []
this.newDeps = []
this.depIds = new Set()
this.newDepIds = new Set()
this.expression = __DEV__ ? expOrFn.toString() : ''
// parse expression for getter
if (isFunction(expOrFn)) {
this.getter = expOrFn
} else {
this.getter = parsePath(expOrFn)
if (!this.getter) {
this.getter = noop
__DEV__ &&
warn(
`Failed watching path: "${expOrFn}" ` +
'Watcher only accepts simple dot-delimited paths. ' +
'For full control, use a function instead.',
vm
)
}
}
this.value = this.lazy ? undefined : this.get()
}
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does constructor() do?
constructor() is a function in the vue codebase, defined in src/core/observer/watcher.ts.
Where is constructor() defined?
constructor() is defined in src/core/observer/watcher.ts at line 67.
What does constructor() call?
constructor() calls 2 function(s): constructor, get.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free