1

I'm new to PromiseKit however I can't get something very basic to work. Consider this:

func test1() -> Promise<Bool> {
    return Promise<Bool>.value(true)
  }

  func test2() -> Promise<Bool> {
    return Promise<Bool> { seal in
      seal.fulfill(true)
    }
  }

  func test3() -> Promise<Bool> {
    return Promise<Bool>.value(true)
  }

The following gives me the error on each line:

Cannot convert value of type Promise<Bool> to closure result type Guarantee<()>

 firstly {
    test1()
  }.then {
    test2()
  }.then {
    test3()
  }.done {

  }.catch {

  }

What am I doing wrong? I've been trying various combinations but nothing seems to work. I'm on PromiseKit 6.13.

Evgeny Karkan
  • 8,782
  • 2
  • 32
  • 38
strangetimes
  • 4,953
  • 1
  • 34
  • 62

1 Answers1

0

From the PromiseKit troubleshooting guide:

Swift does not permit you to silently ignore a closure's parameters.

So you have to just specify closure parameter like below:

firstly {
        test1()
    }.then { boolValue in
        self.test2()
    }.then { boolValue in
        self.test3()
    }.done { _ in

    }.catch { _ in

    }

or even with assigning the _ name to the parameter (acknowledge argument existence but ignoring its name)

firstly {
        test1()
    }.then { _ in
        self.test2()
    }.then { _ in
        self.test3()
    }.done { _ in

    }.catch { _ in

    }
Evgeny Karkan
  • 8,782
  • 2
  • 32
  • 38
  • Thank you! I eventually figured it out after going over the documentation, and I can see what they meant when they say the Swift compiler may throw bogus errors at you. Aargh. Frustrating how it didn't show a more meaningful compiler error. Cannot believe I ended up wasting so much time on something so obvious. – strangetimes Mar 30 '20 at 12:58