# detachable

> This utility allows you to cancel the handling of an asynchronous/delayed callback, even after the invocation of the asynchronous function.

Latest version **1.1.0** (published 2019-11-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install detachable
pnpm add detachable
yarn add detachable
bun add detachable
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2019-11-14 |
| First published | 2019-11-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Raghav Ramesh |
| Maintainers | raghavramesh |
| Keywords | callback, cancellable callback, detachable callback, async |

## Links

- npm: https://www.npmjs.com/package/detachable
- Repository: https://github.com/RaghavRamesh/Detachable
- Homepage: https://github.com/RaghavRamesh/Detachable#readme
- Issues: https://github.com/RaghavRamesh/Detachable/issues
- npm.io page: https://npm.io/package/detachable

## Alternatives

- [promise-throttle](https://npm.io/package/promise-throttle.md) — 44.2K weekly downloads
- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2019-11-14
- 1.0.0 — 2019-11-14

## README

# Detachable
This utility allows you to cancel the handling of an asynchronous/delayed callback, even after the invocation of the asynchronous function.

### How it works
The utility accepts a handler/a list of handlers, and returns a thin wrapper around the original handler(s). If desired, these wrapped handlers can be detached by the handler creator, before they are dispatched. 

Notes: 
- In JavaScript, handlers (callbacks) cannot be prevented from executing. This utility merely prevents the original handlers from executing when the detachable handlers dispatch.
- The simpler alternative would be to use a flag that can be set by the handler creator to indicate that the handlers should prevent their default behaviour (if desired). Depending on the state of this flag, the handlers can perform their default behaviour or otherwise. The value provided by this utility class is that it aids in establishing a more elegant convention that improvescode readability. 

### Acknowledgements
- Developed under the guidance of Ian Loh, Product Team Lead at G Element

---
_Source: https://npm.io/package/detachable · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
