Skip to content

ComponentEx.registerDisposable method

ComponentEx › registerDisposable

Registers a Disposable so it is disposed when this component unloads, and returns it unchanged.

The recurring "tie a disposable to the component's lifecycle, then keep using it" idiom: the disposable is disposed on Component.unload (or earlier, if the caller disposes it directly — dispose is expected to be idempotent). Guard with ensureLoaded at the call site when registering before load would be unsafe.

Signature:

registerDisposable(disposable: TDisposable): TDisposable

Parameters:

ParameterTypeDescription
disposableTDisposableThe disposable to register.

Returns: TDisposableThe same disposable, for chaining.