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
  e9e3ee0b_266d_b038_5ecd_44bb28d26857["constructor()"]
  3fc566ae_243e_2f0a_95d9_c612fe08e096["Observer"]
  e9e3ee0b_266d_b038_5ecd_44bb28d26857 -->|defined in| 3fc566ae_243e_2f0a_95d9_c612fe08e096
  61775709_acae_0dfb_ce5f_30156271b1e7["observeArray()"]
  e9e3ee0b_266d_b038_5ecd_44bb28d26857 -->|calls| 61775709_acae_0dfb_ce5f_30156271b1e7
  dea83477_00f1_3c8b_f0a1_584882807d1f["defineReactive()"]
  e9e3ee0b_266d_b038_5ecd_44bb28d26857 -->|calls| dea83477_00f1_3c8b_f0a1_584882807d1f
  c4420842_db23_0c87_a912_08114ff65982["constructor()"]
  e9e3ee0b_266d_b038_5ecd_44bb28d26857 -->|calls| c4420842_db23_0c87_a912_08114ff65982
  style e9e3ee0b_266d_b038_5ecd_44bb28d26857 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