0
我有我的包裹與無極<牛逼>返回類型的API請求的2:PromiseKit 2.0:鏈接承諾不通過參數
func registerWithEmail(email: String, firstName: String, lastName: String, password: String, subscribe: Bool) -> Promise<Bool>
func requestAccessTokenWithEmail(username: String, password: String) -> Promise<String>
單獨使用的話能正常工作:
firstly {
client.registerWithEmail("[email protected]", firstName: "john", lastName: "smith", password: "password", subscribe: false)
}.then { success -> Void in
completion(success: success)
}.catch { error -> Void in
println(error.localizedDescription)
}
而且:
firstly {
client.requestAccessTokenWithEmail("[email protected]", password: "password")
}.then { accessToken -> Void in
println(accessToken)
completion(success: true)
}.catch { error -> Void in
println(error.localizedDescription)
}
但是,當我鏈接它們時,令牌參數爲s的Econd then
呼叫不會被填充:
firstly {
client.registerWithEmail(username, firstName: "a", lastName: "b", password: password, subscribe: false).then { success -> Void in
return client.requestAccessTokenWithEmail(username, password: password)
}.then { accessToken -> Void in
println(accessToken)
completion(success: true)
}
}
如果我這瓶蓋內打破我無法查看accessToken
說法,只有外部completion
關閉。但是,如果我打破requestAccessTokenWithEmail
函數,則在調用fulfill
時會填充accessToken
參數。
我對PromiseKit相當陌生,所以請讓我知道我是否在做一些愚蠢的事情。
我使用PromiseKit 2.0,1.2斯威夫特,Xcode的6.4