-
Notifications
You must be signed in to change notification settings - Fork 176
Closed
Description
I am having problems getting progress events to propagate up the chain of tasks.
I have a lower level String
task that will generate progress. Then, upon success I want to convert that String
value to in Int
if possible or an error otherwise. I expect progress handlers on both tasks to be called whenever progress changes on the lower level task. Is this a valid expectation?
To be clear, consider the following test (using Nimble) that always fails where indicated below:
class ProgressTest: QuickSpec {
override func spec() {
var stringTask: Task<Float, String, NSError>!
var stringTaskProgressHandler: (Float ->Void)?
var stringTaskProgressValue: Float?
var intTask: Task<Float, Int, NSError>!
var intTaskProgressValue: Float?
beforeEach {
stringTask = Task<Float, String, NSError> { progress, fulfill, reject, configure in
stringTaskProgressHandler = progress
}.progress { oldValue, newValue in
stringTaskProgressValue = newValue
}
intTask = stringTask.success { stringValue -> Task<Float, Int, NSError> in
if let intValue = Int(stringValue) {
return Task(value: intValue)
} else {
return Task(error: NSError(domain: "test", code: 123, userInfo: nil))
}
}.progress { oldValue, newValue in
intTaskProgressValue = newValue
}
}
describe("when string task has progress") {
beforeEach {
stringTaskProgressHandler?(0.5)
}
it("string task progress should fire") {
expect(stringTaskProgressValue).toEventually(equal(0.5))
}
it("should propagate progress to intTask") {
// ************ This test fails! ************
expect(intTaskProgressValue).toEventually(equal(0.5))
}
}
}
}
Thoughts?
Metadata
Metadata
Assignees
Labels
No labels