【问题标题】:PromiseKit 6: Cannot invoke 'then' with an argument list of type '((String, String) -> Promise<Data>)'PromiseKit 6:无法使用类型为“((String,String)-> Promise<Data>)”的参数列表调用“then”
【发布时间】:2018-10-19 11:43:32
【问题描述】:

我有一个返回 Promise&lt;(String, String)&gt;when(fulfilled: [Thenable]),但是当我尝试在 then 块中使用这些参数时,我收到以下错误:

不能使用类型为 '((String, String) -> Promise) 的参数列表调用 'then'

我的代码如下:

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 */ }
   }
}

如果不清楚,auth.currentUserIdPromise()auth.getIdToken() 都解析为 Stringdb.get 返回 promise

我尝试过的事情:

  • 显式表达类型
  • 清理和构建

有谁知道我该如何解决这个问题?

提前致谢:)

【问题讨论】:

    标签: swift promise promisekit


    【解决方案1】:

    我还在 GitHub 上的 PromiseKit 上发布了这个问题,结果发现我使用了错误的“何时”:

    曾是:return when(fulfilled: [auth.currentUserIdPromise(), auth.getIdToken()])

    现在:return when(fulfilled: auth.currentUserIdPromise(), auth.getIdToken())

    前者返回一个数组,而后者返回一个元组。

    https://github.com/mxcl/PromiseKit/issues/943

    【讨论】:

      猜你喜欢
      • 2018-09-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多