Skip to content

Instantly share code, notes, and snippets.

@PxyUp
Last active April 26, 2019 22:16
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 PxyUp/75197285d1b87f6eb90f3490b40cf599 to your computer and use it in GitHub Desktop.
Save PxyUp/75197285d1b87f6eb90f3490b40cf599 to your computer and use it in GitHub Desktop.
CounterComponent
import { bootstrap, Component, rValue, createComponent } from 'revact';
class Counter extends Component {
reactive = {
counter: rValue(0)
}
template = {
tag: "span",
textValue: this.reactive.counter,
listeners: {
click: () => {
this.reactive.counter.value++
}
}
}
}
function createCounter() {
return createComponent(Counter)
}
bootstrap('#first', createCounter)
bootstrap('#second', () => ({
tag: "div",
children: [
{
tag: "textNode",
textValue: "Counter:"
},
createCounter(),
]
}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment