1

My Promise usage looks like -

when(fulfilled: [promise]).then {(response) -> Void in


}.catch { (error) in
    print(error)
}

I'm trying to figure out how i can utilize progress property from when.swift but no luck so far. Thanks in advance. enter image description here

Avi
  • 2,196
  • 18
  • 18

1 Answers1

0

PromiseKit itself has an example:

https://github.com/mxcl/PromiseKit/blob/master/Tests/CorePromise/03_WhenTests.swift#L120-L141

func testProgress() {
    let ex = expectation(description: "")

    XCTAssertNil(Progress.current())

    let p1 = after(.milliseconds(10))
    let p2 = after(.milliseconds(20))
    let p3 = after(.milliseconds(30))
    let p4 = after(.milliseconds(40))

    let progress = Progress(totalUnitCount: 1)
    progress.becomeCurrent(withPendingUnitCount: 1)

    when(fulfilled: p1, p2, p3, p4).done { _ in
        XCTAssertEqual(progress.completedUnitCount, 1)
        ex.fulfill()
    }

    progress.resignCurrent()

    waitForExpectations(timeout: 1, handler: nil)
}
mxcl
  • 26,392
  • 12
  • 99
  • 98