# 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.

- Defined in src/core/scope/scope.js:147

##### Index

### Constructors

constructor

### Properties

$$asyncQueue
$$destroyed
$$listeners
$children
$handler
$id
$parent
$proxy
$root
$target
$value
context
filters
foreignListeners
foreignProxies
functionListeners
objectListeners
propertyMap
scheduled
watchers

### Methods

$apply
$broadcast
$destroy
$emit
$eval
$evalAsync
$getById
$merge
$new
$newIsolate
$on
$postUpdate
$transcluded
$watch
$watchCollection
$watchGroup
checkeListenersForAllKeys
deleteProperty
deregisterForeignKey
deregisterKey
get
notifyListener
registerForeignKey
registerKey
set

## Constructors

### constructor

- new Scope(context?: Scope, parent?: Scope): Scope

  Initializes the handler with the target object and a context.

  #### Parameters

  - `Optional` context: Scope

    The context containing listeners.

  - `Optional` parent: Scope

    Custom parent.

  #### Returns Scope

  - Defined in src/core/scope/scope.js:154

## Properties

### $$asyncQueue

$$asyncQueue: AsyncQueueTask[]

- Defined in src/core/scope/scope.js:213

### $$destroyed

$$destroyed: boolean

- Defined in src/core/scope/scope.js:218
- Defined in src/core/scope/scope.js:1168

### $$listeners

$$listeners: Map<string, Function[]>

- Defined in src/core/scope/scope.js:165

### $children

$children: Scope[]

- Defined in src/core/scope/scope.js:194

### $handler

$handler: Scope

- Defined in src/core/scope/scope.js:183

### $id

$id: number

- Defined in src/core/scope/scope.js:199

### $parent

$parent: Scope

- Defined in src/core/scope/scope.js:206

### $proxy

$proxy: any

Current proxy being operated on

- Defined in src/core/scope/scope.js:180
- Defined in src/core/scope/scope.js:248
- Defined in src/core/scope/scope.js:472
- Defined in src/core/scope/scope.js:474

### $root

$root: Scope

- Defined in src/core/scope/scope.js:204

### $target

$target: any

- Defined in src/core/scope/scope.js:186
- Defined in src/core/scope/scope.js:249
- Defined in src/core/scope/scope.js:527

### $value

$value: any

- Defined in src/core/scope/scope.js:189

### context

context: Scope

- Defined in src/core/scope/scope.js:155

### filters

filters: any[]

- Defined in src/core/scope/scope.js:215

### foreignListeners

foreignListeners: Map<string, Listener[]>

- Defined in src/core/scope/scope.js:168

### foreignProxies

foreignProxies: Set<ProxyConstructor>

- Defined in src/core/scope/scope.js:171

### functionListeners

functionListeners: Map<Function, { fn: Function; oldValue: any }>

- Defined in src/core/scope/scope.js:177

### objectListeners

objectListeners: WeakMap<any, string[]>

- Defined in src/core/scope/scope.js:174

### propertyMap

propertyMap: {
$apply: any;
$broadcast: any;
$children: Scope[];
$destroy: any;
$emit: any;
$eval: any;
$evalAsync: any;
$getById: any;
$handler: Scope;
$id: number;
$isRoot: any;
$merge: any;
$new: any;
$newIsolate: any;
$on: any;
$parent: Scope;
$postUpdate: any;
$proxy: any;
$root: Scope;
$target: any;
$transcluded: any;
$watch: any;
$watchCollection: any;
$watchGroup: any;
notifyListener: any;
registerForeignKey: any;
}

- Defined in src/core/scope/scope.js:477

### scheduled

scheduled: any[]

- Defined in src/core/scope/scope.js:220
- Defined in src/core/scope/scope.js:515
- Defined in src/core/scope/scope.js:576

### watchers

watchers: Map<string, Listener[]>

- Defined in src/core/scope/scope.js:162

## Methods

### $apply

- $apply(expr: any): any

  #### Parameters

  - expr: any

  #### Returns any

  - Defined in src/core/scope/scope.js:1003

### $broadcast

- $broadcast(name: string, ...args: any[]): any

  #### Parameters

  - name: string
  - ...args: any[]

  #### Returns any

  - Defined in src/core/scope/scope.js:1047

### $destroy

- $destroy(): void

  #### Returns void

  - Defined in src/core/scope/scope.js:1148

### $emit

- $emit(name: string, ...args: any[]): void

  #### Parameters

  - name: string
  - ...args: any[]

  #### Returns void

  - Defined in src/core/scope/scope.js:1035

### $eval

- $eval(expr: any, locals: any): any

  #### Parameters

  - expr: any
  - locals: any

  #### Returns any

  - Defined in src/core/scope/scope.js:971

### $evalAsync

- $evalAsync(expr: any, locals: any): Promise<any>

  #### Parameters

  - expr: any
  - locals: any

  #### Returns Promise<any>

  - Defined in src/core/scope/scope.js:993

### $getById

- $getById(id: string | number): Scope

  Searches the scope instance

  #### Parameters

  - id: string | number

  #### Returns Scope

  - Defined in src/core/scope/scope.js:1215

### $merge

- $merge(newTarget: any): void

  #### Parameters

  - newTarget: any

  #### Returns void

  - Defined in src/core/scope/scope.js:997

### $new

- $new(childInstance: any): any

  #### Parameters

  - childInstance: any

  #### Returns any

  - Defined in src/core/scope/scope.js:881

### $newIsolate

- $newIsolate(instance: any): any

  #### Parameters

  - instance: any

  #### Returns any

  - Defined in src/core/scope/scope.js:908

### $on

- $on(name: any, listener: any): () => void

  #### Parameters

  - name: any
  - listener: any

  #### Returns () => void

  - Defined in src/core/scope/scope.js:1011

### $postUpdate

- $postUpdate(fn: any): void

  #### Parameters

  - fn: any

  #### Returns void

  - Defined in src/core/scope/scope.js:1144

### $transcluded

- $transcluded(parentInstance: any): any

  #### Parameters

  - parentInstance: any

  #### Returns any

  - Defined in src/core/scope/scope.js:916

### $watch

- $watch(
  watchProp: string,
  listenerFn?: ListenerFunction,
  lazy?: boolean,
  ): () => void

  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.

  - `Optional` listenerFn: ListenerFunction

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

  - `Optional` lazy: boolean = false

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

  #### Returns () => void

  - Defined in src/core/scope/scope.js:609

### $watchCollection

- $watchCollection(watchProp: any, listenerFn: any): () => void

  #### Parameters

  - watchProp: any
  - listenerFn: any

  #### Returns () => void

  - Defined in src/core/scope/scope.js:877

### $watchGroup

- $watchGroup(watchArray: any, listenerFn: any): void

  #### Parameters

  - watchArray: any
  - listenerFn: any

  #### Returns void

  - Defined in src/core/scope/scope.js:873

### checkeListenersForAllKeys

- checkeListenersForAllKeys(value: any): void

  #### Parameters

  - value: any

  #### Returns void

  - Defined in src/core/scope/scope.js:441

### deleteProperty

- deleteProperty(target: any, property: any): boolean

  #### Parameters

  - target: any
  - property: any

  #### Returns boolean

  - Defined in src/core/scope/scope.js:555

### deregisterForeignKey

- deregisterForeignKey(key: any, id: any): boolean

  #### Parameters

  - key: any
  - id: any

  #### Returns boolean

  - Defined in src/core/scope/scope.js:955

### deregisterKey

- deregisterKey(key: any, id: any): boolean

  #### Parameters

  - key: any
  - id: any

  #### Returns boolean

  - Defined in src/core/scope/scope.js:939

### get

- get(
  target: any,
  property: string | number | symbol,
  proxy: ProxyConstructor,
  ): any

  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: any

    The target object.

  - property: string | number | symbol

    The name of the property being accessed.

  - proxy: ProxyConstructor

    The proxy object being invoked

  #### Returns any

  - The value of the property or a method if accessing `watch` or `sync`.
  - Defined in src/core/scope/scope.js:467

### notifyListener

- notifyListener(listener: Listener, target: any): void

  Invokes the registered listener function with watched property changes.

  #### Parameters

  - listener: Listener

    The property path that was changed.

  - target: any

  #### Returns void

  - Defined in src/core/scope/scope.js:1176

### registerForeignKey

- registerForeignKey(key: any, listener: any): void

  #### Parameters

  - key: any
  - listener: any

  #### Returns void

  - Defined in src/core/scope/scope.js:931

### registerKey

- registerKey(key: any, listener: any): void

  #### Parameters

  - key: any
  - listener: any

  #### Returns void

  - Defined in src/core/scope/scope.js:923

### set

- set(target: any, property: string, value: any, proxy: any): boolean

  Intercepts and handles property assignments on the target object. If a new value is an object, it will be recursively proxied.

  #### Parameters

  - target: any

    The target object.

  - property: string

    The name of the property being set.

  - value: any

    The new value being assigned to the property.

  - proxy: any

  #### Returns boolean

  - Returns true to indicate success of the operation.
  - Defined in src/core/scope/scope.js:232