Last active
December 31, 2015 09:34
-
-
Save alebon/12c4639dc4218b2ea614 to your computer and use it in GitHub Desktop.
This file contains 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
object JsFunctions { | |
// Some more code here, using the buildServiceFunctions method | |
def buildServerFunctions(name: String, funcs: List[RoundTripInfo], session: Box[LiftSession]): JsCmd = { | |
JsRaw("""lift_serverFunctions().apply('%s', %s)""" | |
.format(name, session.getOrElse(throw new Exception("Session required")).buildRoundtrip(funcs).toJsCmd).stripMargin).cmd | |
} | |
} |
This file contains 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
trait NgAccountService extends NgService { | |
def ngAccountServerFunctions(xhtml: NodeSeq): NodeSeq = { | |
val serverFunctionMappings = List[RoundTripInfo]( | |
"signup" -> this.ngAccountService_signup _) | |
this.applyService("accountService", serverFunctionMappings) | |
} | |
/** | |
* Sends activation mail (with activation link) | |
* | |
* @param emailValue | |
* @return | |
*/ | |
protected def ngAccountService_signup(emailValue: String): JsonAST.JValue = { | |
// Some BL here | |
val hostAndPath = S.hostAndPath | |
// Response value | |
} | |
} |
This file contains 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
class NgPublic extends StatefulSnippet | |
with NgAccountService { | |
override def dispatch: DispatchIt = { | |
case "accountService" => ngAccountServerFunctions | |
} | |
} |
This file contains 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
trait NgService extends Logger { | |
protected implicit lazy val formats = DefaultFormats | |
/** | |
* Helper method to simplify ngServices | |
* | |
* @param serverFunctionMappings | |
*/ | |
protected def applyService(serviceName: String, serverFunctionMappings: List[RoundTripInfo]): NodeSeq = { | |
S.putAtEndOfBody(JsFunctions.serverFunctions(serviceName, serverFunctionMappings, S.session)) | |
NodeSeq.Empty | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment