Function watch

  • Watch the changed properties of a State (Reactive object).

    Type Parameters

    Parameters

    • state: Reactive<T>

      Reactive object to watch.

    • Optional debounce: number

      Debounce time in ms.

    Returns Reactive<History<T>>

    Example

    const form = reactive({ verified: false });
    const history = watch(form);

    form.name = 'John';

    // Logs: { name: 'John' }
    console.log(history.changes);

    Undo the changes.

    Example

    const form = reactive({ verified: false });
    const history = watch(form);

    form.name = 'Smith';

    // Logs: { name: 'Smith' }
    console.log(history.changes);

    history.undo();
    // Logs: {}
    console.log(history.changes);

Generated using TypeDoc