webani - v1.0.0
    Preparing search index...

    WebaniVariable is a class that represents a variable that can be set and reacted to by different change handlers. It can handle changes both from its own internal mechanism (onValueSetFromSelf) and from external sources (parent variables).

    The value of the WebaniVariable can be either set directly or derived from a function. This class supports the monitoring of changes in the variable's value and allows for callbacks to be executed when the value changes.

    Type Parameters

    • T

      The type of the value stored within the variable.

    Indexable

    • [key: string]: unknown
    Index

    Constructors

    • Creates an instance of a WebaniVariable with an optional value. If the value is a function, it sets the value based on the result of that function, and prevents further value changes directly.

      Type Parameters

      • T

      Parameters

      • value: T

        The initial value for the variable. This can either be a value of type T, or a function returning a value of type T.

      Returns WebaniVariable<T>

    Properties

    logReads: boolean = false

    Flag indicating whether variable reads should be logged (static).

    readLogs: WebaniVariable<unknown>[] = []

    Logs for tracking variable reads (static).

    Accessors

    • set _rawValue(val: T): void

      Sets the raw value of the variable and updates any nested objects if the value is an object.

      Parameters

      • val: T

        The raw value to set for the variable.

      Returns void

    • set _valueFromParent(val: T): void

      Sets the value of the variable from the parent and triggers the associated change handlers.

      Parameters

      • val: T

        The value to set from the parent.

      Returns void

    • set _valueFromSelf(val: T): void

      Sets the value of the variable from within itself and triggers the associated change handlers.

      Parameters

      • val: T

        The value to set from within the variable.

      Returns void

    Methods