lit-helpers
A utility library for Lit 2
Installation
npm install @stefanholzapfel/lit-helpers
This package includes some helper controllers and directives.
Reactive controllers
DomDetachmentController
Programmatically add callbacks to execute when LitElement is detached from DOM.
@customElement('my-element')
export class MyElement extends LitElement{
// Create the controller and store it
private domDetachmentController = new DomDetachmentController(this);
anyElementFunction() {
this.domDetachmentController.addLogic(() => {
// do something, e.g. clean up dynamically created subscriptions
})
}
}