There is a newer version of the record available.

Published April 28, 2026 | Version @anywidget/vite@0.3.0
Software Open

anywidget

Authors/Creators

  • 1. Harvard Medical School

Description

Minor Changes

  • Add signal (AbortSignal) to initialize and render props for lifecycle cleanup (#974)

    Both initialize and render now receive an AbortSignal via the signal prop. The signal is aborted when the widget is destroyed (or during HMR). This is the preferred way to manage cleanup going forward — it composes with the broader web platform (addEventListener, fetch, child widgets) and avoids the need to manually track teardown logic.

    The previous callback-based pattern continues to work but is no longer recommended:

    // before
    export default {
      render({ model, el }) {
        let handler = () => { /* ... */ };
        model.on("change:value", handler);
        return () => model.off("change:value", handler);
      },
    };
    
    // after
    export default {
      render({ model, el, signal }) {
        let handler = () => { /* ... */ };
        model.on("change:value", handler);
        signal.addEventListener("abort", () => model.off("change:value", handler));
      },
    };
    

    signal also works with addEventListener and fetch directly:

    export default {
      render({ model, el, signal }) {
        el.addEventListener(
          "click",
          () => {
            /* ... */
          },
          { signal }
        );
      },
    };
    

Files

manzt/anywidget-@anywidget/vite@0.3.0.zip

Files (9.9 MB)

Name Size Download all
md5:d8a25aa016c279ff159c4bb891dcbddd
9.9 MB Preview Download

Additional details

Related works

Software