Last active
August 29, 2015 14:12
-
-
Save ncammarata/360050d0e11f302f6ae4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # Front end | |
| api = connectAPI "https://localhost:3000" | |
| Colors = api.collection 'colors' | |
| colors = Colors | |
| << sortBy .name | |
| App { | |
| state: { colors, activeColor: Nothing } | |
| actions: { | |
| like color: Colors.set color.id { likes: color.likes + 1 } | |
| } | |
| template: | |
| h1 My Favorite Colors | |
| .empty(if: empty @colors) No colors yet | |
| ul | |
| li(repeat<color>: @colors | |
| class<active>: @activeColor == color | |
| click: @activeColor = color | |
| ) {.likes} people like {.name} | |
| .footer(if: @activeColor) | |
| button(click: :like @activeColor) Like! | |
| } | |
| # Server in coffeescript | |
| Flint = require('Flint') | |
| api = Flint.api() | |
| colors = api.collection 'colors', Flint.mongo(mongoConnection) | |
| api.run(3000) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment