toolish - v0.2.5
    Preparing search index...

    Class Reactive<T>Abstract

    Base class representing a reactive entity.

    Type Parameters

    • T

    Hierarchy (View Summary)

    Implements

    Index

    Constructors

    Properties

    DIRECT_CACHE: WeakReactiveCache = ...
    NESTED_CACHE: WeakReactiveCache = ...
    NO_CACHE: ReactiveCache = NO_CACHE
    NO_TRACK: SubscriptionTracker = NO_TRACK

    Methods

    • Creates a ReactiveDerivative that contains the property with the given name when the underlying value is an object, or the element at the given index when the underlying value is an array. You can use a negative index to count back from the end.

      Type Parameters

      • K extends string | number | symbol

      Parameters

      • key: K

        property name or index

      Returns ReactiveDerivative<Unreactive<T[K]>>

      • Performing this on a value that is not indexable (a primitive) results in a runtime error. TypeScript prevents this at compile time, there are no additional checks at runtime.
      • An invalid property name yields undefined. TypeScript prevents this at compile time, there are no additional checks at runtime.
      • An out-of-bounds index also yields undefined. TypeScript does not normally prevent this at compile time as it hides the potential undefined! There are also no additional checks at runtime because this may be intentional. If you expect an index to be valid you can ensure this with something like ...select(101).derive(expectPresent).
    • Select 2 levels deep

      Type Parameters

      • K1 extends string | number | symbol
      • T2 extends unknown
      • K2 extends string | number | symbol

      Parameters

      Returns ReactiveDerivative<Unreactive<T2[K2]>>

    • Select 3 levels deep

      Type Parameters

      • K1 extends string | number | symbol
      • T2 extends unknown
      • K2 extends string | number | symbol
      • T3
      • K3 extends string | number | symbol

      Parameters

      Returns ReactiveDerivative<Unreactive<T3[K3]>>

    • Select 4 levels deep

      Type Parameters

      • K1 extends string | number | symbol
      • T2 extends unknown
      • K2 extends string | number | symbol
      • T3
      • K3 extends string | number | symbol
      • T4
      • K4 extends string | number | symbol

      Parameters

      Returns ReactiveDerivative<Unreactive<T4[K4]>>

    • Select 5 levels deep

      Type Parameters

      • K1 extends string | number | symbol
      • T2 extends unknown
      • K2 extends string | number | symbol
      • T3
      • K3 extends string | number | symbol
      • T4
      • K4 extends string | number | symbol
      • T5
      • K5 extends string | number | symbol

      Parameters

      Returns ReactiveDerivative<Unreactive<T5[K5]>>

    • Select more than 5 levels deep without type checking. Consider combining multiple selects with a maximum depth of 5 instead.

      Parameters

      • ...keys: (string | number | symbol)[]

      Returns ReactiveDerivative<unknown>

    • Let subscribers (reactive dependants) know that this value has changed. Make sure to always call this after manually mutating a reactive value. Mutations through ReactiveValue.set and other library APIs do this for you.

      Note that not all reactive values are expected to be mutated directly. ReactiveValue and its subclasses are, but ReactiveDerivative is not!

      Returns void

      someMutation(reactiveValue.unwrap());
      reactiveValue.updateSubscribers();