Reactive APIs
    Preparing search index...
    • Listens for events on the specified event source and invokes the callback for each event.

      The source parameter can be a plain event source, a signal, or a reactive function that returns the event source.

      on returns a cleanup handle that should be used to stop listening for the event.

      Example:

      import { on } from "@conterra/reactivity-events";

      const view = ...;
      const handle = on(view.clicked, (event) => {
      console.log("Clicked at", event.x, event.y);
      });
      // Later, to clean up:
      handle.destroy();

      The event source parameter can be reactive. In the following example, we will always subscribe on the current view (and unsubscribe from the previous one):

      // model.getCurrentView() is implemented using signals
      const handle = on(() => model.getCurrentView().clicked, (event) => {
      console.log("Clicked at", event.x, event.y);
      });

      Type Parameters

      • T

      Parameters

      Returns CleanupHandle