I have a when(fulfilled: [Thenable])
that returns Promise<(String, String)>
, however when I try to use these arguments in my then
block I receive the following error:
Cannot invoke 'then' with an argument list of type '((String, String) -> Promise)
My code is as follows:
func fetchAll(includeClosed: Bool) -> Promise<AccountInformation> {
return when(fulfilled: [auth.currentUserIdPromise(), auth.getIdToken()])
.then { (uid, token) in self.db.get(userID: uid, uri: "accounts", token: token) }
.then { /* Some more stuff */ }
}
}
In case it isn't clear, auth.currentUserIdPromise()
and auth.getIdToken()
both resolve to String
and db.get
returns a promise
.
Things I've tried:
Does anyone know how I can resolve this issue?
Thanks in advance :)
I also posted this question to PromiseKit on GitHub and it turns out I was using the wrong 'when':
WAS: return when(fulfilled: [auth.currentUserIdPromise(), auth.getIdToken()])
NOW: return when(fulfilled: auth.currentUserIdPromise(), auth.getIdToken())
The former returns an array, whereas the latter returns a tuple.