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

    Function modelSignal

    • Function

      Parameters

      • ...keys: KeyType[]

        The key path into the model's data. Defaults to the decorated member name if omitted.

      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

      modelSignal

      Stage-3 decorator that turns a field on a GradumModel into a reactive property stored in the model's data, rather than on the instance. Use it for state that must be persisted or synced — on a GradumYModel the value lives in the underlying Y.js structure. Use @signal instead for state that should stay in memory.

      class TodoModel extends GradumModel {
      @modelSignal() title = "";
      @modelSignal("meta", "author") author = "";
      }

      Is equivalent to:

      class TodoModel extends GradumModel {
      @signal get title() { return this.get("title"); }
      set title(value) { this.set(value, "title"); }

      @signal get author() { return this.get("meta", "author"); }
      set author(value) { this.set(value, "meta", "author"); }
      }