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
  90ef1d3a_2785_5dda_2141_19e108797c9d["constructor()"]
  2c74d940_5549_d682_16cc_0c643fff7d8d["Observer"]
  90ef1d3a_2785_5dda_2141_19e108797c9d -->|defined in| 2c74d940_5549_d682_16cc_0c643fff7d8d
  17657a1e_b0a2_0135_b657_5fa134adbfec["observeArray()"]
  90ef1d3a_2785_5dda_2141_19e108797c9d -->|calls| 17657a1e_b0a2_0135_b657_5fa134adbfec
  772e5b8f_95bc_3463_fed7_f1034ba985e1["defineReactive()"]
  90ef1d3a_2785_5dda_2141_19e108797c9d -->|calls| 772e5b8f_95bc_3463_fed7_f1034ba985e1
  f85018be_e0a0_2003_eea0_3ff58670fc4b["constructor()"]
  90ef1d3a_2785_5dda_2141_19e108797c9d -->|calls| f85018be_e0a0_2003_eea0_3ff58670fc4b
  style 90ef1d3a_2785_5dda_2141_19e108797c9d 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, defined in src/core/observer/index.ts.
Where is constructor() defined?
constructor() is defined in src/core/observer/index.ts at line 52.
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