Class ReactivePrimitivePrivate

ReactivePrimitive is the base class for all reactive items. It provides methods for subscribing to changes, getting the current value, and checking for errors.

Hierarchy (view full)

Constructors

Properties

engine: Engine
name: string = ""

Accessors

Methods

  • Removes all subscribers, including listeners for "#has-subscribers" and "#no-subscribers" events.

    Returns void

  • Removes all "change" subscribers. Listeners for "#has-subscribers" and "#no-subscribers" are not removed.

    Returns void

  • Destroys the reactive item. This method is useful for cleaning up after a reactive item that is no longer needed. It calls destroy on the engine of the reactive item, which removes all dependencies, dependents and subscribers, and marks the engine as destroyed.

    Returns void

  • Checks if two values are equal. If the compareFn property is a function, it is used to compare the two values. If the compareFn property is not a function, the values are compared using the === operator. If the optional second argument is not provided, the value of the reactive item is used.

    Parameters

    • a: any

      The first value to compare.

    • Optional b: any

      The second value to compare. If not provided, the value of the reactive item is used.

    Returns boolean

    True if the two values are equal, false otherwise.

  • Returns the last error that occurred while calculating the value of the reactive item, or null if there is no error.

    Returns Error

    The last error that occurred, or null if there is no error.

  • Retrieves the current value of the reactive item.

    Parameters

    • Optional options: {
          untracked: boolean;
      }

      Optional options.

      • untracked: boolean

        If true, the value will not be added to the getValueTracker.

    Returns any

    The current value of the reactive item.

  • Returns true if there has been an error while calculating the value of the reactive item, false otherwise. This method returns true if the reactive item has been destroyed, if the reactive item has an error, or if the calculation of the value of the reactive item has thrown an error.

    Returns boolean

    Whether there has been an error while calculating the value of the reactive item.

  • Subscribes a function to be called when the reactive item is destroyed. The function is called with no arguments.

    Parameters

    • fn: ((reactiveItem) => void)

      The function to be called.

    Returns (() => void)

    A function that unsubscribes the given function.

      • (): void
      • Returns void

  • Subscribes a function to be called whenever a subscriber is added to the reactive item. The function is called with no arguments.

    Parameters

    • fn: (() => void)

      The function to be called.

        • (): void
        • Returns void

    Returns (() => void)

    A function that unsubscribes the given function.

      • (): void
      • Returns void

  • Subscribes a function to be called whenever there are no longer any subscribers. The function is called with no arguments.

    Parameters

    • fn: (() => void)

      The function to be called.

        • (): void
        • Returns void

    Returns (() => void)

    A function that unsubscribes the given function.

      • (): void
      • Returns void

  • Subscribes a function to be called whenever the value of this reactive item changes.

    Parameters

    • fn: ((updates) => void)

      The function to be called whenever the value of this reactive item changes.

    • Optional options: {
          delay: number;
          signal: AbortSignal;
      }

      Optional options.

      • delay: number

        The delay in milliseconds before the function is called.

      • signal: AbortSignal

        The signal to abort the subscription.

    Returns Unsubscriber