PromiseKit如何回归"何时(已解决)"作为承诺?

时间:2017-10-22 23:23:30

标签: swift asynchronous promise promisekit

我有一系列看起来像这样的函数:

func getA() -> Promise<Void> {
  // code
}

func getB() -> Promise<Void> {
  // code
}

func getC() -> Promise<Void> {
  // code
}

我想在完成所有这些后返回Promise。这就是我的尝试:

func getStuff() -> Promise<[Result<Void>]> {
  return when(resolved: [getA(), getB(), getC()])
}

但是我收到了编译错误:'Result' is ambiguous for type lookup in this context。我怎样才能做到这一点?

1 个答案:

答案 0 :(得分:0)

您的代码中有几个名为Result的内容,您需要告诉Swift,在这种情况下Result引用PromiseKit.Result或使用Resolution假设它不在命名空间中,你不关心相关的ErrorConsumptionToken。

func getStuff() -> Promise<[Resolution<Void>]> {
  return when(resolved: [getA(), getB(), getC()])
}
相关问题