https://github.com/re-js/unsubscriber
How to easy collect unsubscribe functions for several sources
https://github.com/re-js/unsubscriber
detach unsubscribe unsubscriber
Last synced: 4 months ago
JSON representation
How to easy collect unsubscribe functions for several sources
- Host: GitHub
- URL: https://github.com/re-js/unsubscriber
- Owner: re-js
- License: mit
- Created: 2022-07-16T09:09:42.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-11-30T23:27:01.000Z (over 1 year ago)
- Last Synced: 2025-02-15T12:42:30.649Z (4 months ago)
- Topics: detach, unsubscribe, unsubscriber
- Language: TypeScript
- Homepage:
- Size: 104 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# unsubscriber
[](https://www.npmjs.com/package/unsubscriber)
[](https://bundlephobia.com/result?p=unsubscriber)
[](https://coveralls.io/github/re-js/unsubscriber)
[](index.d.ts)How to easy collect unsubscribe functions from several sources.
```javascript
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:
```javascript
const app = collect(usubs, () => {const detach = un(unsubscriber);
});
```Enjoy your code!