signal-disposer

1.0.1 • Public • Published

About

'signal-disposer'' is a library for managing and disposing events in JavaScript and TypeScript. It provides a simple and efficient way to handle event management in complex applications.

Features

  • Signal: A signal class that can be used to emit events and connect listeners.
  • DisposableGroup: A group of disposable objects that can be disposed together.

Install

npm install signal-disposer
# or
yarn add signal-disposer

Usage

import { Signal, DisposableGroup } from "signal-disposer";

const signal = new Signal();
signal.connect(() => {
	console.log("Signal emitted!");
});

// connect once
signal.once(() => {
	console.log("only execute once!");
});

// dispose
const disposable = signal.connect(() => {
	console.log("dispose me!");
});
disposable.dispose();

// dispose group
const group = new DisposableGroup();
group.add(
	signal.connect(() => {
		console.log("dispose group!");
	}),
);
group.dispose();

License

MIT

Package Sidebar

Install

npm i signal-disposer

Weekly Downloads

2

Version

1.0.1

License

MIT

Unpacked Size

13.7 kB

Total Files

8

Last publish

Collaborators

  • pzppzz