unsubscriber
TypeScript icon, indicating that this package has built-in type declarations

2.2.0 • Public • Published

unsubscriber

npm version bundle size code coverage typescript supported

How to easy collect unsubscribe functions from several sources.

import { unsubscriber, collect, attach, run, scope, un } from "unsubscriber";

const unsubs = unsubscriber();

// Run code and collect unsubscribers
const app = collect(usubs, () => {
  un(() => {
    console.log('unsubscribe');
  });

  attach(scope(), () => {});
  return new App();
});

const detach = attach(usubs, () => {});

run(usubs);

Context dependent functions who available into the function body:

const app = collect(usubs, () => {

  const detach = un(unsubscriber);

});

Enjoy your code!

Package Sidebar

Install

npm i unsubscriber

Weekly Downloads

158

Version

2.2.0

License

MIT

Unpacked Size

11 kB

Total Files

13

Last publish

Collaborators

  • betula