Skip to content

BlockSuite API Documentation / @blocksuite/lit / WithDisposable

Function: WithDisposable()

WithDisposable<T>(SuperClass): T & Constructor<DisposableClass>

Mixin that adds a _disposables: DisposableGroup property to the class.

The _disposables property is initialized in connectedCallback and disposed in disconnectedCallback.

see https://lit.dev/docs/composition/mixins/

Type parameters

T extends Constructor<LitElement>

Parameters

SuperClass: T

Returns

T & Constructor<DisposableClass>

Example

ts
class MyElement extends WithDisposable(ShadowlessElement) {
  onClick() {
    this._disposables.add(...);
  }
}

Source

packages/framework/lit/src/with-disposable.ts:27