Skip to content

Instantly share code, notes, and snippets.

@PxyUp
Last active April 26, 2019 22:15
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/00f0b878da68d99ecbc1f12fcdef77ec to your computer and use it in GitHub Desktop.
Save PxyUp/00f0b878da68d99ecbc1f12fcdef77ec to your computer and use it in GitHub Desktop.
fasterDom If
import { createComponent, Component, rValue, bootstrap} from 'revact';
class Comp extends Component {
reactive = {
show: rValue(true),
text: rValue("Here timer")
}
get show() {
return this.reactive.show;
}
get text() {
return this.reactive.text
}
onClick = () => {
this.show.value = !this.show.value;
this.text.value = this.show.value ? "Here timer" : "Sorry not timer"
}
template = {
tag: "div",
children: [
{
tag: "p",
children: [
{
tag: "span",
textValue: "Current value:"
},
{
tag: "span",
textValue: this.show
},
]
},
{
tag: "button",
listeners: {
click: this.onClick,
},
textValue: "Change state"
},
{
tag: "div",
textValue: "You will see me always"
},
{
tag: "div",
show: this.show,
textValue: "You will sometimes"
}, {
tag: "div",
children: [
{
tag: "strong",
textValue: this.text
},
]
}
]
}
}
function createComp() {
return createComponent(Comp)
}
bootstrap('#app', createComp)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment