npm.io
0.1.9 • Published 3 years ago

lit-singleton

Licence
MIT
Version
0.1.9
Deps
1
Size
47 kB
Vulns
0
Weekly
0

Lit Singleton

A library to make singleton-like elements in lit

The issue

It's known that in a web page there are components that might only be required once at the time(e.g. alerts, snackbars)

And, by their nature, they need to be accesible in all parts of the code.

This library, helps you make singleton-like web components, ina fairly easy way

Installation

npm i lit-singleton

Usage

import { Singleton } from 'lit-singleton';
@customElement('web-component')
class WebComponent extends Singleton{
    static generator?: (() => LitElement) = () => (document.createElement('web-component') as LitElement);
}