map.apps Bundle APIs 4.20.0
    Preparing search index...

    Function notifyChange

    • Helper to trigger custom change notification.

      Type Parameters

      • M extends unknown

      Parameters

      • instance: M

        the instance which property.

      • name: Extract<keyof Properties<M>>

        the name of the changed property.

      Returns void

      import {declare, notifyChange} from "apprt-core/Mutable";
      let globalCounter = 0;
      const Clazz = declare({
      counter: {
      get() {
      return globalCounter;
      }
      }
      });

      const instance = new Clazz();
      instance.watch("counter", ({ value }) => {
      console.log(`count: ${value}`);
      });

      // ensure that external counter can be watched
      globalCounter++;
      notifyChange(instance, "counter");
      //-> count: 1