BlockSuite API Documentation / @blocksuite/block-std / 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/block-std/src/view/utils/with-disposable.ts:27