Last active
April 26, 2019 22:15
-
-
Save PxyUp/00f0b878da68d99ecbc1f12fcdef77ec to your computer and use it in GitHub Desktop.
fasterDom If
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 { 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