npm.io
0.0.37 • Published 6 years ago

@reactive-js/disposable

Licence
MIT
Version
0.0.37
Deps
1
Size
19 kB
Vulns
0
Weekly
0
Stars
11
DeprecatedThis package is deprecated

@reactive-js/disposable

Utilities for managing the lifetimes of resources and composing their disposal semantics.

Installation

via npm

npm install @reactive-js/disposable
via yarn
yarn add @reactive-js/disposable

Usage

import { createDisposable } from "@reactive-js/disposable";

const arr = new Array(1000);
const onDispose = () => {
  arr.length = 0;
};
const disposable = createDisposable();
disposable.add(onDispose);

// ...sometime in the future

disposable.dispose();
// guaranteed that onDispose is only ever called once.

Documentation

API documentation is available here.

Keywords