Created
January 22, 2017 21:53
-
-
Save anonymous/59df078b34ce3b58969b16c647466583 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
# Counter | |
## State | |
``` | |
commit | |
[#state count: 0] | |
commit @browser | |
[#button sort: 0, text: "-", diff: -1] | |
[#button sort: 1, text: "+", diff: 1] | |
``` | |
## Render | |
``` | |
search | |
[#state count] | |
bind @browser | |
[#div sort: 10 text: count] | |
``` | |
## Event | |
``` | |
search @session @event @browser | |
element = [#button diff] | |
[#click #direct-target element: element] | |
state = [#state count] | |
commit @session @browser | |
state.count := state.count + diff | |
[#div text: "{{element.diff}} {{state.count}}"] | |
``` | |
## Styles | |
```css | |
button { | |
display: inline-block; | |
width: 22px; | |
color: green; | |
} | |
button[diff='-1'] { | |
color: red; | |
} | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment