Last active
August 26, 2020 14:47
-
-
Save deebloo/8c3feb3c4d80877d07a17e71c5eb5979 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { component, State, handle, JoistElement, get } from '@joist/component'; | |
import { template, html } from '@joist/component/lit-html'; | |
@component({ | |
tagName: 'my-counter', | |
state: 0, | |
render: template(({ state, run }) => { | |
return html` | |
<button @click=${run('decrement')}>-</button> | |
<span>${state}</span> | |
<button @click=${run('increment')}>+</button> | |
` | |
}) | |
}) | |
class AppElement extends JoistElement { | |
@get(State) | |
private state!: State<number>; | |
@handle('increment') | |
increment() { | |
this.state.setValue(this.state.value + 1); | |
} | |
@handle('decrement') | |
decrement() { | |
this.state.setValue(this.state.value - 1); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment