0

I have a series of functions that look like this:

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

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

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

I want to return a Promise when all of these are finished. Here's what I tried:

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

But I'm getting a compile error: 'Result' is ambiguous for type lookup in this context. How can I achieve this?

7ball
  • 2,183
  • 4
  • 26
  • 61

2 Answers2

1
func getStuff() -> Promise<[PromiseKit.Result<Void>]> {
    return when(resolved: [getA(), getB(), getC()])
}
mxcl
  • 26,392
  • 12
  • 99
  • 98
0

There are several things named Result in your code and you need to tell Swift that Result in this case refers to PromiseKit.Result or to use Resolution assuming it's not taken in the namespace and you don't care about the related ErrorConsumptionToken.

func getStuff() -> Promise<[Resolution<Void>]> {
  return when(resolved: [getA(), getB(), getC()])
}
Benjamin Gruenbaum
  • 270,886
  • 87
  • 504
  • 504