@nexim/element
Version:
Utility functions and mixins for building high-performance web components with Lit.
34 lines • 1.15 kB
TypeScript
import { type AlwatrLogger } from '@alwatr/logger';
import type { Class } from '@alwatr/type-helper';
import type { LitElement } from 'lit';
/**
* Interface for elements that have a logger instance.
* @noInheritDoc
*/
export interface LoggerMixinInterface extends LitElement {
logger_: AlwatrLogger;
}
/**
* Create a mixin class that extends the provided superclass and logs the lifecycle methods of the element.
*
* Hint: function super() must be called in the methods to logger work.
* @typeParam T - The base class to extend.
*
* @returns A mixin class that extends the superclass and logs the lifecycle methods of the element.
*
* @example
* ```ts
* import {LitElement, html} from 'lit';
* import {LoggerMixin} from '@nexim/element';
*
* class MyElement extends LoggerMixin(LitElement) {
* protected override render() {
* super.render(); // must call super method to logger work
*
* return html`<p>Hello, world!</p>`;
* }
* }
* ```
*/
export declare function loggerMixin<T extends Class<LitElement> = Class<LitElement>>(superClass: T): Class<LoggerMixinInterface> & T;
//# sourceMappingURL=logging.d.ts.map