Class: AvenxWatcher

AvenxWatcher(getter, callbackopt, optionsopt)

AvenxWatcher handles dependency tracking, caching, lazy/immediate callbacks, and lifecycle cleanup for reactive expressions.

Constructor

new AvenxWatcher(getter, callbackopt, optionsopt)

Parameters:
Name Type Attributes Default Description
getter function | Array:.<function()>

The reactive evaluation function.

callback function | null <optional>
null

Callback triggered when evaluated value changes.

options object <optional>

Configuration options.

Properties
Name Type Attributes Description
immediate boolean <optional>

Run the callback immediately with initial value.

lazy boolean <optional>

Postpone the initial evaluation until first accessed.

Source:

Classes

AvenxWatcher

Members

callback :function|null

Type:
  • function | null
Source:

debounceTimer :any

Type:
  • any
Source:

deps :Set:.<{target:: object:, key:: string:, watchersSet:: Set:.<AvenxWatcher:>}>

Type:
  • Set:.<{target:: object:, key:: string:, watchersSet:: Set:.<AvenxWatcher:>}>
Source:

dirty :boolean

Type:
  • boolean
Source:

getter :function|Array:.<function()>

Type:
  • function | Array:.<function()>
Source:

isArray :boolean

Type:
  • boolean
Source:

isEffect :boolean

Type:
  • boolean
Source:

lastExecTime :number

Type:
  • number
Source:

name :string

Type:
  • string
Source:

options :object

Type:
  • object
Source:

pendingNewValue :any

Type:
  • any
Source:

pendingOldValue :any

Type:
  • any
Source:

throttleTimer :any

Type:
  • any
Source:

value :any

Type:
  • any
Source:

Methods

addDep(target, key, watchersSet)

Registers a target property dependency on this watcher.

Parameters:
Name Type Description
target object

Reactive object target.

key string

Property key.

watchersSet Set:.<AvenxWatcher:>

Set mapping to this dependency.

Source:

cleanupDeps(oldDeps)

Compares active dependencies against old dependencies and unsubscribes from stale dependencies.

Parameters:
Name Type Description
oldDeps Set:.<{target:: object:, key:: string:, watchersSet:: Set:.<AvenxWatcher:>}>
Source:

evaluate() → {any}

Evaluates a lazy computed watcher if it is dirty.

Source:
Returns:
Type
any

get() → {any}

Evaluates the getter function inside the watcher context to track reactive dependencies.

Source:
Returns:
Type
any

pause()

Pauses watcher execution.

Source:

resume()

Resumes watcher execution.

Source:

run(newValue, oldValue)

Executes the watcher callback, applying debounce or throttle timing if configured.

Parameters:
Name Type Description
newValue any
oldValue any
Source:

teardown()

Cleans up all registered dependencies of this watcher to prevent memory leaks.

Source:

update()

Updates the watcher value and triggers evaluation or callback execution.

Source: