Amazon Vinyl
    Preparing search index...

    Interface MutableValue<T>

    A mutable version of a data provider.

    interface MutableValue<T> {
        changeId: number;
        value: T;
        getValue(): T;
        invalidate(): void;
        map<U>(transform: (value: T) => U): ObservableValue<U>;
        map<U>(
            transform: (value: T) => U,
            setData: (transformed: U, original: T) => T,
        ): MutableValue<U>;
        onData(callback: DataChangedCallback<T>): Unsubscribe;
        pick<K extends string | number | symbol>(
            prop: K,
        ): MutableValue<Picked<T, K>>;
        pick(prop: PropertyKey): MutableValue<unknown>;
        setValue(value: T): void;
    }

    Type Parameters

    • T

    Hierarchy (View Summary)

    Index
    changeId: number

    A monotonically increasing id that increments before each change notification.

    value: T

    The current value, may be set. onData callbacks will be invoked if value is not exactly equal to the current value.

    • Invokes subscribers, can be used to indicate a change without setting a new value.

      Returns void

    • Creates a readonly sub-controller for a transformed value.

      Type Parameters

      • U

      Parameters

      • transform: (value: T) => U

        Applies a transformation to a single value using a provided function and returns the result. The returned sub controller will use this as its value.

      Returns ObservableValue<U>

    • Creates a writable sub-controller for a transformed value.

      Type Parameters

      • U

      Parameters

      • transform: (value: T) => U

        Applies a transformation to a single value using a provided function and returns the result. The returned sub controller will use this as its value.

      • setData: (transformed: U, original: T) => T

        The reverse of transform; When the sub-controller's data is set, this will convert the transformed value back to what can be saved on this controller.

      Returns MutableValue<U>

    • Sets the current value.

      Parameters

      • value: T

      Returns void