我想弄清楚如何鏈接多個異步調用並返回結果。我目前正在嘗試異步用戶數據,並異步更新用戶數據並返回結果,但它似乎不工作:( 我使用map {result => Ok(result)},但仍認爲我是返回一個對象。任何幫助嗎?玩斯卡拉2.4鏈接異步調用
def updateUserData() = Action.async { implicit request =>
updateUserForm.bindFromRequest.fold(
errors => Future.successful(BadRequest(views.html.authenticated.settings.settings_hero(errors, Option(""), Option("")))),
{
case (userData) =>
request.session.get("email") match {
case Some(email) =>
getUser(email, userData.curent_password) map { userCheck =>
if (userCheck) {
updateUserOnService(email, userData.f_name, userData.l_name, userData.new_password) map { result =>
Ok("please")
}
//val e = updateUserOnService(email, userData.f_name, userData.l_name, userData.new_password) map {result => Ok("")}
// user is valid now update the user data
// call removeAuth to log out
// redirect to home
///Ok (updateUserOnService(email, userData.f_name, userData.l_name, userData.new_password) map { result => result})
//Redirect(routes.settings.index()).addingToSession("email" -> email)
} else {
BadRequest(views.html.authenticated.settings.settings_hero(updateUserForm.bindFromRequest.withGlobalError(Messages("error.login", email)), Option(""), Option("")))
}
}
}
})
}
主要部分,我有問題是這一部分。我認爲這是一些語法問題。有人能幫忙嗎? 感謝
updateUserOnService(email, userData.f_name, userData.l_name, userData.new_password) map { result =>
Ok("please")
}
你能分享的方法簽名(更具體的返回類型):'getUser'和'updateUserOnService'。沒有它,我們很難推斷出我們腦海中的類型:) –
在我們的IDE中。 :-) –
def updateUserOnService(email:String,firstName:String,lastName:String,n_password:String)= {0121} { 「email」 - > Seq(email),「firstName」 - > Seq(firstName),「lastName」 - > Seq(lastName),「n_password」 - > Seq(n_password))) –