pdf-lite - v1.0.1
    Preparing search index...

    Class Ref<T>

    A mutable reference wrapper that supports value updates and change notifications. Can hold a direct value or reference another Ref, forming reference chains.

    const ref = new Ref(42)
    ref.onUpdate((old, newVal) => console.log(`Changed from ${old} to ${newVal}`))
    ref.update(100) // Logs: Changed from 42 to 100

    Type Parameters

    • T

      The value type being referenced

    Index

    Constructors

    • Creates a new Ref with an initial value.

      Type Parameters

      • T

      Parameters

      • value: T | Ref<T>

        The initial value or another Ref to chain

      Returns Ref<T>

      Error if attempting to create a self-referencing Ref

    Properties

    callbacks: RefUpdateCallback<T>[] = []

    Registered callbacks for update notifications

    isModified: boolean = false
    value: T | Ref<T>

    The current value or a reference to another Ref

    Methods

    • Compares this Ref's resolved value with another value or Ref.

      Parameters

      • Optionalother: T | Ref<T>

        The value or Ref to compare against

      Returns boolean

      True if the resolved values are equal

    • Updates the reference to a new value or another Ref. Notifies all registered callbacks of the change.

      Parameters

      • newValue: T | Ref<T>

        The new value or Ref to point to

      Returns void