
Security News
GitHub Actions Pricing Whiplash: Self-Hosted Actions Billing Change Postponed
GitHub postponed a new billing model for self-hosted Actions after developer pushback, but moved forward with hosted runner price cuts on January 1.
disposables
Advanced tools
This project works fine but is not actively maintained.
For the new code, you might want to try the new official rx.disposables package instead.
Disposables let you safely compose resource disposal semantics.
Think DOM nodes, event handlers, socket connections.
This implementation of disposables is extracted from RxJS.
I took the liberty to tweak the code style to my liking and provide this as a standalone package.
This tiny package includes several disposables:
Disposable ensures its dispose action runs only once;CompositeDisposable ensures a group of disposables are disposed together;SerialDisposable switches underlying disposables on the fly and disposes them.The API is mostly the same as RxJS except stricter in a few places.
It does not strive for 100% API compatibility with RxJS, but generally behavior is the same.
It's best if you consult the source and tests, as classes are small and few.
import { Disposable, CompositeDisposable, SerialDisposable } from 'disposables';
// or you can import just the ones you need to keep it even tinier
// import SerialDisposable from 'disposables/modules/SerialDisposable';
function attachHandlers(node) {
let someHandler = ...;
node.addEventHandler(someHandler);
// use Disposable to guarantee single execution
return new Disposable(() => {
node.removeEventHandler(someHandler);
});
}
// CompositeDisposable lets you compose several disposables...
let nodes = ...;
let compositeDisp = new CompositeDisposable(nodes.map(attachHandlers));
// and more later...
let moreNodes = ...
moreNodes.map(attachHandlers).forEach(d => compositeDisp.add(d));
// and dispose them at once!
function goodbye() {
compositeDisp.dispose();
}
// ... or replace with a bunch of new ones ...
let serialDisp = new SerialDisposable();
serialDisp.setDisposable(compositeDisp);
function replaceNodes(newNodes) {
let nextCompositeDisp = new CompositeDisposable(newNodes.map(attachHandlers));
// release all the previous disposables:
serialDisp.setDisposable(nextCompositeDisp);
}
// with a guarantee of each dispose() called only once.
Like the original RxJS code, it is licensed under Apache 2.0.
FAQs
Disposables let you safely compose resource disposal semantics
The npm package disposables receives a total of 60,914 weekly downloads. As such, disposables popularity was classified as popular.
We found that disposables demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
GitHub postponed a new billing model for self-hosted Actions after developer pushback, but moved forward with hosted runner price cuts on January 1.

Research
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.

Security News
Socket CTO Ahmad Nassri shares practical AI coding techniques, tools, and team workflows, plus what still feels noisy and why shipping remains human-led.