Skip to content

Memory Management

Store unsubscribe handles and call them during cleanup:

ts
const stops = [lifecycle.on("page:visible", onVisible), lifecycle.on("page:hidden", onHidden)];

function cleanup() {
  for (const stop of stops) stop();
  void lifecycle.dispose();
}

Registering anonymous listeners without a matching unsubscribe path.

Production recommendation

Wire cleanup into framework teardown (useEffect return, onUnmounted, ngOnDestroy).

JOC is a JayOnCode monorepo of @jayoncode/* packages. Docs sync from source via TypeDoc and sync scripts.