@vandeurenglenn/lite
v0.2.52
Published
## install
Downloads
97
Readme
lite
install
npm i @vandeurenglenn/lite
usage
import { LiteElement, property, query, state, html, css, customElement } from '@vandeurenglenn/lite'
@customElement('some-element')
class SomeElement extends LiteElement {
@property()
accessor items = ['hello', 'world']
render() {
return html`${this.items.map((item) => html`${item}`)}`
}
}
provides/consumes
basic data binding using pubsub
consumes
import { LiteElement, property, html, customElement } from '@vandeurenglenn/lite'
@customElement
class ConsumerEl extends LiteElement {
@property({ consumes: true, type: Array })
accessor items
@property({ consumes: 'someunique-id', type: Boolean })
accessor drawerOpen
render() {
return html`${this.items.map((item) => html`${item}`)}`
}
}
provides
import { LiteElement, property, customElement } from '@vandeurenglenn/lite'
@customElement
class ProviderEl extends LiteElement {
@property({ provides: true })
accessor items = ['hello', 'world']
@property({ provides: 'someunique-id', type: Boolean })
accessor drawerOpen = false
}
onChange
import { LiteElement, property, customElement } from '@vandeurenglenn/lite'
@customElement
class ProviderEl extends LiteElement {
@property({ type: Boolean })
accessor drawerOpen = false
// runs after render
onChange(propertyKey, value) {}
}
willChange
import { LiteElement, property, customElement } from '@vandeurenglenn/lite'
@customElement
class ProviderEl extends LiteElement {
@property({ type: Boolean })
accessor drawerOpen = false
// runs before render
willChange(propertyKey, value) {
return value // always return
}
}