0.1.1 • Published 1 year ago

@-ft/disposer v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Util - Disposer

compose multiple disposables easily into single disposable

Usage

function SomeEffect() {
  useEffect(() => {
    const timeout = setInterval(() => console.log('Hello world!'), 1000);
    const handler = (e) => e.stopPropagation();
    document.body.addEventListener('click', handler, true);
    return new Disposer()
      .add(() => clearInterval(timeout))
      .add(() => document.removeEventListener('click', handler, true))
      .disposable();
  }, []);
  return null;
}
0.1.1

1 year ago

0.1.0

1 year ago