AngularTS
    Preparing search index...

    Class Scope

    Scope class for the Proxy. It intercepts operations like property access (get) and property setting (set), and adds support for deep change tracking and observer-like behavior.

    Indexable

    • [key: string]: unknown
    • [key: number]: unknown
    • [key: symbol]: unknown
    Index

    Constructors

    • Initializes the handler with the target object and a context.

      Parameters

      • Optionalcontext: Scope

        The context containing listeners.

      • Optionalparent: Scope

        Custom parent.

      Returns Scope

    Properties

    $handler: this
    $id: number
    $parent?: Scope
    $proxy: Scope
    $root: Scope
    $scopename?: string
    $target: ScopeTarget

    Methods

    • Runs synchronous scope mutations as one batch. Listener notifications are queued while the callback runs and flushed once after the outermost batch exits. Mutations are not rolled back if the callback throws.

      Type Parameters

      • T

      Parameters

      • fn: () => T

      Returns T

    • Broadcasts an event downward through the scope hierarchy.

      Parameters

      • name: string
      • ...args: unknown[]

      Returns ScopeEvent

    • Returns void

    • Emits an event upward through the scope hierarchy.

      Parameters

      • name: string
      • ...args: unknown[]

      Returns ScopeEvent

    • Searches this scope tree for a scope with the given id.

      Parameters

      • id: string | number

      Returns Scope | undefined

    • Merges enumerable properties from the provided object into the current scope target.

      Parameters

      • newTarget: object

      Returns void

    • Creates a prototypically inherited child scope.

      Parameters

      • OptionalchildInstance: Scope

      Returns Scope

    • Creates an isolate child scope that does not inherit watchable properties directly.

      Parameters

      • Optionalinstance: Scope

      Returns Scope

    • Registers an event listener on this scope and returns a deregistration function.

      Parameters

      • name: string
      • listener: (...args: unknown[]) => unknown

      Returns () => void

    • Searches the scope tree for a scope registered under the provided name.

      Parameters

      • name: string

      Returns Scope | undefined

    • Creates a transcluded child scope linked to this scope and an optional parent instance.

      Parameters

      • OptionalparentInstance: Scope

      Returns Scope

    • Registers a watcher for a property along with a listener function. The listener function is invoked when changes to that property are detected.

      Parameters

      • watchProp: string

        An expression to be watched in the context of this model.

      • OptionallistenerFn: (newValue?: unknown, originalTarget?: object) => void

        A function to execute when changes are detected on watched context.

      • Optionallazy: boolean = false

        A flag to indicate if the listener should be invoked immediately. Defaults to false.

      Returns (() => void) | undefined

      A function to deregister the watcher, or undefined if no listener function is provided.

      Error when watchProp is not a string expression.

    • Parameters

      • target: ScopeTarget

        The target object.

      • property: string | number | symbol

        The name of the property being deleted.

      Returns boolean

    • Intercepts property access on the target object. It checks for specific properties (watch and sync) and binds their methods. For other properties, it returns the value directly.

      Parameters

      • target: ScopeTarget

        The target object.

      • property: string | number | symbol

        The name of the property being accessed.

      • proxy: Scope

        The proxy object being invoked.

      Returns unknown

      The value of the property or a method if accessing watch or sync.

    • Intercepts and handles property assignments on the target object. Scopeable objects are stored as raw model values and proxied lazily when read.

      Parameters

      • target: ScopeTarget

        The target object.

      • property: string

        The name of the property being set.

      • value: unknown

        The new value being assigned to the property.

      • proxy: Scope

        The proxy intercepting property access.

      Returns boolean

      Returns true to indicate success of the operation.