A Reference offers a simple mechanism for referring to properties by reference.

interface Reference<T> {
    expired: boolean;
    location: Location;
    original: T;
    owner?: T;
    rootOwner?: any;
    subrefs?: Record<string | number, Val.Reference<unknown>>;
    value: T;
    change(mutator: (() => void)): void;
    refresh(): void;
}

Type Parameters

Properties

expired: boolean

When true, the reference is no longer usable because the owning context has exited.

location: Location

Diagnostic path to the referenced value.

original: T

The current canonical value of the referenced property.

owner?: T

The managed value that owns the reference.

rootOwner?: any

The object that owns the root managed value.

subrefs?: Record<string | number, Val.Reference<unknown>>

Active references to child properties.

value: T

The current value of the referenced property. Cleared when the reference is no longer functional.

Methods

  • Mutates data. Clones the container and updates metadata when called on an unmodified transactional reference.

    Then runs the specified mutator to make the actual changes.

    Parameters

    • mutator: (() => void)

      the mutation logic, may freely modify value

        • (): void
        • Returns void

    Returns void