Skip to content

Instantly share code, notes, and snippets.

Created January 22, 2017 21:53
Show Gist options
  • Save anonymous/59df078b34ce3b58969b16c647466583 to your computer and use it in GitHub Desktop.
Save anonymous/59df078b34ce3b58969b16c647466583 to your computer and use it in GitHub Desktop.
# 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