Home / File/ effectScope.ts — vue Source File

effectScope.ts — vue Source File

Architecture documentation for effectScope.ts, a typescript file in the vue codebase. 2 imports, 0 dependents.

File typescript CompilerSFC StyleProcessor 2 imports 4 functions 1 classes

Entity Profile

Dependency Diagram

graph LR
  3c2912c4_0eac_a88d_e983_87f8f7c62fb5["effectScope.ts"]
  816bcd3b_1a7f_7b21_ab25_7a23681aea66["watcher"]
  3c2912c4_0eac_a88d_e983_87f8f7c62fb5 --> 816bcd3b_1a7f_7b21_ab25_7a23681aea66
  8a5fb776_a8f4_ce8a_8549_67af07f2e1e9["util"]
  3c2912c4_0eac_a88d_e983_87f8f7c62fb5 --> 8a5fb776_a8f4_ce8a_8549_67af07f2e1e9
  style 3c2912c4_0eac_a88d_e983_87f8f7c62fb5 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import Watcher from 'core/observer/watcher'
import { warn } from 'core/util'

export let activeEffectScope: EffectScope | undefined

export class EffectScope {
  /**
   * @internal
   */
  active = true
  /**
   * @internal
   */
  effects: Watcher[] = []
  /**
   * @internal
   */
  cleanups: (() => void)[] = []
  /**
   * @internal
   */
  parent: EffectScope | undefined
  /**
   * record undetached scopes
   * @internal
   */
  scopes: EffectScope[] | undefined
  /**
   * indicates this being a component root scope
   * @internal
   */
  _vm?: boolean
  /**
   * track a child scope's index in its parent's scopes array for optimized
   * removal
   */
  private index: number | undefined

  constructor(public detached = false) {
    this.parent = activeEffectScope
    if (!detached && activeEffectScope) {
      this.index =
        (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(
          this
        ) - 1
    }
  }

  run<T>(fn: () => T): T | undefined {
    if (this.active) {
      const currentEffectScope = activeEffectScope
      try {
        activeEffectScope = this
        return fn()
      } finally {
        activeEffectScope = currentEffectScope
      }
    } else if (__DEV__) {
      warn(`cannot run an inactive effect scope.`)
    }
// ... (78 more lines)

Domain

Subdomains

Classes

Dependencies

  • util
  • watcher

Frequently Asked Questions

What does effectScope.ts do?
effectScope.ts is a source file in the vue codebase, written in typescript. It belongs to the CompilerSFC domain, StyleProcessor subdomain.
What functions are defined in effectScope.ts?
effectScope.ts defines 4 function(s): effectScope, getCurrentScope, onScopeDispose, recordEffectScope.
What does effectScope.ts depend on?
effectScope.ts imports 2 module(s): util, watcher.
Where is effectScope.ts in the architecture?
effectScope.ts is located at src/v3/reactivity/effectScope.ts (domain: CompilerSFC, subdomain: StyleProcessor, directory: src/v3/reactivity).

Analyze Your Own Codebase

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

Try Supermodel Free