Skip to content

Instantly share code, notes, and snippets.

@ncammarata
Last active August 29, 2015 14:12
Show Gist options
  • Select an option

  • Save ncammarata/360050d0e11f302f6ae4 to your computer and use it in GitHub Desktop.

Select an option

Save ncammarata/360050d0e11f302f6ae4 to your computer and use it in GitHub Desktop.
# 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