Home / Function/ constructor() — vue Function Reference

constructor() — vue Function Reference

Architecture documentation for the constructor() function in index.ts from the vue codebase.

Entity Profile

Dependency Diagram

graph TD
  b461461c_321d_dc69_edbd_d6367a4ffb41["constructor()"]
  3934f985_209c_9657_436f_ea20137ae833["observeArray()"]
  b461461c_321d_dc69_edbd_d6367a4ffb41 -->|calls| 3934f985_209c_9657_436f_ea20137ae833
  558ee358_0776_b0dd_fc5b_6c8f87e1a04e["defineReactive()"]
  b461461c_321d_dc69_edbd_d6367a4ffb41 -->|calls| 558ee358_0776_b0dd_fc5b_6c8f87e1a04e
  9220325a_3cfc_e259_1511_c64f33af5490["constructor()"]
  b461461c_321d_dc69_edbd_d6367a4ffb41 -->|calls| 9220325a_3cfc_e259_1511_c64f33af5490
  style b461461c_321d_dc69_edbd_d6367a4ffb41 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/core/observer/index.ts lines 52–85

  constructor(public value: any, public shallow = false, public mock = false) {
    // this.value = value
    this.dep = mock ? mockDep : new Dep()
    this.vmCount = 0
    def(value, '__ob__', this)
    if (isArray(value)) {
      if (!mock) {
        if (hasProto) {
          /* eslint-disable no-proto */
          ;(value as any).__proto__ = arrayMethods
          /* eslint-enable no-proto */
        } else {
          for (let i = 0, l = arrayKeys.length; i < l; i++) {
            const key = arrayKeys[i]
            def(value, key, arrayMethods[key])
          }
        }
      }
      if (!shallow) {
        this.observeArray(value)
      }
    } else {
      /**
       * Walk through all properties and convert them into
       * getter/setters. This method should only be called when
       * value type is Object.
       */
      const keys = Object.keys(value)
      for (let i = 0; i < keys.length; i++) {
        const key = keys[i]
        defineReactive(value, key, NO_INITIAL_VALUE, undefined, shallow, mock)
      }
    }
  }

Domain

Subdomains

Frequently Asked Questions

What does constructor() do?
constructor() is a function in the vue codebase.
What does constructor() call?
constructor() calls 3 function(s): constructor, defineReactive, observeArray.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free