Skip to content

Instantly share code, notes, and snippets.

@deebloo
Last active August 6, 2020 16:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deebloo/81ade0ccd5aa5eb412b84f991bc5b8d1 to your computer and use it in GitHub Desktop.
Save deebloo/81ade0ccd5aa5eb412b84f991bc5b8d1 to your computer and use it in GitHub Desktop.
import { component, State, JoistElement, get } from '@joist/component';
import { template, html } from '@joist/component/lit-html'
@component<number>({
tagName: 'my-counter',
state: 0,
render: template(({ state }) => html`${state}`)
})
class MyCounterElement extends JoistElement {
@get(State)
private state!: State<number>;
connectedCallback() {
super.connectedCallback();
setInterval(() => this.update(), 1000);
}
private update() {
const { value } = this.state;
this.state.setValue(value + 1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment