turbodombuilder - v0.9.5
    Preparing search index...

    Function observe

    • Type Parameters

      • Type extends object
      • Value

      Parameters

      • 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>

      Returns any

      Stage-3 decorator for fields, getters, setters, and accessors that reflects a property to an HTML attribute. So when the value of the property changes, it is reflected in the element's HTML attributes. It also records the attribute name into the class'sobservedAttributed to listen for changes on the HTML.

      @define()
      class MyClass extends HTMLElement {
      @observe fieldName: string = "hello";
      }

      Leads to:

      <my-class field-name="hello"></my-class>