• Helper to trigger custom change notification.

    Type Parameters

    • M extends unknown

    Parameters

    • instance: M

      the instance which property.

    • name: Extract<keyof Properties<M>, PropertyKey>

      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