gitwtfhub

wtf is disposables?

gaearon/disposables — explained in plain English

Analysis updated 2026-07-17 · repo last pushed 2018-01-07

62JavaScriptAudience · developerComplexity · 2/5DormantSetup · easy

TL;DR

A tiny JavaScript library, extracted from RxJS, that reliably cleans up event listeners, connections, and subscriptions exactly once and never twice.

Mindmap

mindmap
  root((repo))
    What it does
      Disposable
      CompositeDisposable
      SerialDisposable
    Tech stack
      JavaScript
      RxJS origin
    Use cases
      Remove event listeners
      Swap resources safely
      Group cleanups
    Audience
      JavaScript developers

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Why would anyone build with this?

REASON 1

Group multiple event listener cleanups with CompositeDisposable and remove them all with one dispose() call.

REASON 2

Guarantee a cleanup function runs exactly once using the basic Disposable wrapper.

REASON 3

Safely swap old resources for new ones with SerialDisposable, ensuring the old ones are disposed first.

REASON 4

Manage lifecycle cleanup for subscriptions or DOM connections in a framework or library.

What's in the stack?

JavaScript

How it stacks up

gaearon/disposables1utkarsh1/mcp-stdio-guardrion-wu-tech/grok-video-workflow
Stars626161
LanguageJavaScriptJavaScriptJavaScript
Last pushed2018-01-07
MaintenanceDormant
Setup difficultyeasyeasymoderate
Complexity2/52/52/5
Audiencedeveloperdevelopervibe coder

Figures from each repo's GitHub metadata at analysis time.

How do you spin it up?

Difficulty · easy Time to first run · 5min

Package is not actively maintained, README suggests newer alternatives for new projects.

Yoink these prompts

Prompt 1
Show me how to use CompositeDisposable to group five DOM event listener cleanups and remove them all at once.
Prompt 2
Help me use SerialDisposable to swap out an old event listener for a new one, disposing the old one first.
Prompt 3
Explain how Disposable guarantees a cleanup function only runs once, even if dispose() is called multiple times.
Prompt 4
Walk me through integrating disposables into a component's unmount lifecycle to clean up all its event listeners.
Prompt 5
What are modern alternatives to the disposables package for resource cleanup in a new JavaScript project?

Frequently asked questions

wtf is disposables?

A tiny JavaScript library, extracted from RxJS, that reliably cleans up event listeners, connections, and subscriptions exactly once and never twice.

What language is disposables written in?

Mainly JavaScript. The stack also includes JavaScript.

Is disposables actively maintained?

Dormant — no commits in 2+ years (last push 2018-01-07).

How hard is disposables to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is disposables for?

Mainly developer.

View the repo → Decode another repo

This repo across BitVibe Labs

Don't trust strangers blindly. Verify against the repo.