Skip to content
/ dispose Public

A library for managing and disposing events. It provides a simple and efficient way to handle event management in complex applications.

License

Notifications You must be signed in to change notification settings

pzppzz/dispose

Repository files navigation

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

About

A library for managing and disposing events. It provides a simple and efficient way to handle event management in complex applications.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published