0.2.1 • Published 3 years ago

disposable-events v0.2.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

disposable-events

Build status Maintainability Coverage Issues Repo size

What does it do

Disposables are convenient ways to represent a resource you will no longer need at some point. You can instantiate a disposable with an action to take when no longer needed.

Inspired by the atom's event-kit

How do you use it

Coming soon™️

DisposableCollection

You can use DisposableCollection to combine disposable instances together.

const { Disposable, DisposableCollection } = require('disposable-events')

const subscriptions = new DisposableCollection()
subscriptions.add(
  new Disposable(() => alert('asd')),
  new Disposable(() => alert('basd'))
)

// Later, to unsubscribe from *both*...
subscriptions.dispose()