Skip to content

shared/disposable

Defined in: app/src/shared/disposable.ts:36

Collects disposables and releases them together, in reverse order of addition.

Once disposed, the store disposes anything added later immediately, so late registrations cannot leak.

new DisposableStore(): DisposableStore

DisposableStore

get isDisposed(): boolean

Defined in: app/src/shared/disposable.ts:41

Whether DisposableStore.dispose has been called.

boolean

add<T>(item): T

Defined in: app/src/shared/disposable.ts:50

Adds a disposable to the store.

T extends Disposable

T

The disposable to own.

T

The same disposable, for chaining.

dispose(): void

Defined in: app/src/shared/disposable.ts:64

Disposes every item in reverse order. Errors are collected and rethrown after all items were disposed, so one failing cleanup does not keep others alive.

void

AggregateError when one or more items failed to dispose.

Disposable.dispose

Defined in: app/src/shared/disposable.ts:7

Something that holds resources and releases them when Disposable.dispose is called.

Every registration in the browser (a command, an IPC handler, an event listener, a UI slot) returns a Disposable, so that a module can be switched off without leaks.

dispose(): void

Defined in: app/src/shared/disposable.ts:9

Releases the resources. Calling it more than once has no further effect.

void

isDisposable(value): value is Disposable

Defined in: app/src/shared/disposable.ts:87

Tells whether a value implements Disposable.

unknown

Any value.

value is Disposable


toDisposable(cleanup): Disposable

Defined in: app/src/shared/disposable.ts:17

Wraps a cleanup function in a Disposable that runs it at most once.

() => void

Function that releases the resource.

Disposable

A disposable that calls cleanup on the first dispose().