gradum-kit - v0.1.0
    Preparing search index...

    Function nestedModelSignal

    • Function

      Parameters

      • ...keys: string[]

        The key path navigating to the nested model.

      Returns <Type extends object, Value>(
          value:
              | {
                  get?: (this: Type) => Value;
                  set?: (this: Type, value: Value) => void;
              }
              | ((initial: Value) => Value)
              | ((this: Type) => Value)
              | ((this: Type, v: Value) => void),
          context:
              | ClassFieldDecoratorContext<Type, Value>
              | ClassGetterDecoratorContext<Type, Value>
              | ClassSetterDecoratorContext<Type, Value>
              | ClassAccessorDecoratorContext<Type, Value>,
      ) => any

      nestedModelSignal

      Stage-3 decorator that exposes a nested collection as a GradumModel rather than as raw data. Reading the property gives back the nested model, so you can attach a GradumObserver to it; assigning replaces the data it wraps. Use it when you need to observe a collection — reach for @modelSignal when the raw value is enough.

      class AppModel extends GradumModel {
      @nestedModelSignal("users", "42") user = undefined;
      }

      Is equivalent to:

      class AppModel extends GradumModel {
      @signal get user() { return this.getNested("users", "42"); }
      set user(value) { this.getNested("users", "42").data = value; }
      }