wcb/examples/demo/Counter.mjs
Ayo Ayco 73dd374a3e
feat: attach-effect (#2)
We are now able to attach "side effects" to property value changes, from inside the component and outside.
2023-12-01 08:42:10 +01:00

15 lines
365 B
JavaScript

// @ts-check
import WebComponent from "../../src/WebComponent.js";
export class Counter extends WebComponent {
static properties = ["count"];
onInit() {
this.props.count = 0;
this.onclick = () => ++this.props.count;
}
get template() {
return `<button id="btn">${this.props.count}</button>`;
}
}
customElements.define("my-counter", Counter);