this repo has no description
1import { useEffect } from 'preact/hooks';
2
3function useCloseWatcher(fn, deps = []) {
4 if (!fn || typeof fn !== 'function') return;
5 useEffect(() => {
6 const watcher = new CloseWatcher();
7 watcher.addEventListener('close', fn);
8 return () => {
9 watcher.destroy();
10 };
11 }, deps);
12}
13
14export default window.CloseWatcher ? useCloseWatcher : () => {};