Click here to load reader
Upload
gilttech
View
8.181
Download
0
Embed Size (px)
DESCRIPTION
Nathan Hamblen gives a lightning talk about Scala
Citation preview
Scala for the Web Will it blend? def ol(items: Seq[String]) = <ol> { items.map { s => <li> { s } </li> } } </ol>
Scala is hybrid. λ + ☃ = ?
Lift Ajax.scala // create an ajax select box def doSelect(msg: NodeSeq) = ajaxSelect((1 to 50).toList.map { i => (i.toString, i.toString) }, Full(1.toString), { v => DisplayMessage(msgName, bind("sel", msg, "number" -> Text(v)), 5 seconds, 1 second) }) // bind the view to the functionality bind("select" -> doSelect _, ... ajax.html
<ajax:select> You selected <sel:number></sel:number> From the select box. </ajax:select>
Scalate • Mustache • Scaml • Jade • SSP
XML literals. Seriously. val myDiv = <div>Yo</div>
Scalatra class MyScalatraFilter extends ScalatraFilter { get("/") { <html> <body> <h1>Hello, world!</h1> </body> </html> } } def ol(items: Seq[String]) = <ol> { items.map { s => <li> { s } </li> } } </ol>
Unfiltered import unfiltered.request._ import unfiltered.response._ val echo = unfiltered.filter.Planify {
case Path(Seg(p :: Nil)) => ResponseString(p) } unfiltered.jetty.Http.anylocal.filter(echo).run() object Stream extends unfiltered.netty.async.Plan with ServerErrorResponse { val ChunkedMp3 = unfiltered.response.Connection(HttpHeaders.Values.CLOSE) ~> TransferEncoding(HttpHeaders.Values.CHUNKED) ~> ContentType("audio/mp3") val listeners = new DefaultChannelGroup def intent = { case req => val initial = req.underlying.defaultResponse(ChunkedMp3) val ch = req.underlying.event.getChannel ch.write(initial).addListener { () => listeners.add(ch) } } ...
Scala for the Web Yes, it blends! http://meetup.com/ny-scala