Scala,Liftand theRealTimeWeb
DavidPollak
BenevolentDictatorforLife LiftWebFramework dpp@liftweb.net
Scala,Liftand theRealTimeWeb DavidPollak BenevolentDictatorforLife - - PowerPoint PPT Presentation
Scala,Liftand theRealTimeWeb DavidPollak BenevolentDictatorforLife LiftWebFramework dpp@liftweb.net Allaboutme(DavidPollak) Sometimesstrict,mostlylazy
BenevolentDictatorforLife LiftWebFramework dpp@liftweb.net
(except Happs)
ListenerManager { private var msgs: List[String] = Nil protected def createUpdate = Messages(msgs)
case s: String if s.length > 0 => msgs ::= s updateListeners() } this.start }
class Chat extends CometActor with CometListenee { private var msgs: List[String] = Nil def render = <div> <ul>{msgs.reverse.map(m => <li>{m}</li>)}</ul> {ajaxText("", s => {ChatServer ! s; Noop})} </div> protected def registerWith = ChatServer
case Messages(m) => msgs = m ; reRender(false) } }
case Messages(m) => msgs = m case s: String if s.length > 0 => msgs ::= s Matchagainstcaseclasses
Type8safecasting Awesomedeclarativewayofexpressinglogic
Female with Runner
womansRun(sally)
msgs.reverse.map(m => <li>{m}</li>) ajaxText("", s => {ChatServer ! s; Noop}) map takesafunctionasaparameter
Functionsareinstancesandcanbepassed Functionscanbeputin Mapsforlateruse
c <- ca.text.split(" ")} yield c Find all the classes used by <p> tags
case Req(ApiPath :: "statuses" :: "public_timeline" :: Nil, this.method, GetRequest) => publicTimeline def publicTimeline(): Box[TwitterResponse] = { val statusList = Message.findAll(OrderBy(Message.id, Descending), MaxRows(20)). map(msgData _) Full(Right(Map("statuses" -> ("status", statusList) ))) }
Scala’sobjectmodelisasupersetofJava’s Scala’straits:super8powerfulclasscomposition Scalaismoretype8safethanJava ScalaissyntacticallysimplerthanJavaorRuby ScalaisasconciseasRuby ScalahasawesomelibrariesincludingActors WhatifJava,Ruby,andHaskellhasalove8child? Scala’sdesignledtoLift’sdesign Lift’sdesignmakestheRealTimeWebsuper8simple