Skip to content

Instantly share code, notes, and snippets.

@erikpukinskis
Created June 17, 2015 03:01
Show Gist options
  • Save erikpukinskis/aa3d1e017fabd2202621 to your computer and use it in GitHub Desktop.
Save erikpukinskis/aa3d1e017fabd2202621 to your computer and use it in GitHub Desktop.
element = require "nrtv-element"
component = require "nrtv-component"
BridgeTie = require "nrtv-bridge-tie"
ServerTie = require "nrtv-server-tie"
ElementTie = require "nrtv-element-tie"
GimmePizza = component(BridgeTie, ServerTie, ElementTie)
server = GimmePizza.server()
bridge = GimmePizza.bridge()
Success = element.template.container ".success",
element.style
background: "lightgreen"
color: "green"
border: "1px solid green"
padding: "4px 8px",
successMessage = GimmePizza.element ".hidden",
[Success("your pizza is ready yo")]
showSuccess = successMessage.showOnClient(bridge)
makePizza = server.route "post",
"/pizzas",
(x, response) ->
response.json showSuccess
button = GimmePizza.element "button",
".gimme",
"GIMME PIZZA!",
onclick: makePizza.makeRequest(bridge)
body = element("body", [
button,
successMessage
element.stylesheet(Success)
])
server.route "get", "/",
bridge.sendPage(body)
gimme = new GimmePizza()
gimme.start(9991)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment