turbodombuilder - v0.9.66
    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

      Decorator that binds a reactive signal to a key path in the model's data, read via this.get(...keys) and written via this.set(value, ...keys).

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

      Is equivalent to:

      class TodoModel extends TurboModel {
      @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"); }
      }