useWindowSignal
useWindowSignal():
AbortSignal
Defined in: renderer/hooks/useWindowState.ts:50
Returns an AbortSignal that fires when the window closes or releases
back to its pool. Pass to addEventListener, fetch, observers, etc.
for automatic cleanup on window close.
The signal is WINDOW-scoped, not component-scoped — if your component may unmount while the window stays open (conditional rendering), you still need a useEffect cleanup return. Prefer useWindowEventListener which handles both cases.
Returns
Section titled “Returns”AbortSignal
Example
Section titled “Example”const signal = useWindowSignal();const doc = useWindowDocument();useEffect(() => { doc.addEventListener("keydown", onKey, { signal }); // signal removes on WINDOW close. Still return cleanup for // COMPONENT unmount (e.g. conditional <Panel> inside a window): return () => doc.removeEventListener("keydown", onKey);}, [signal, doc]);