In most case, there is only one error catch and chain for the successful operation. But for my case, what I want to do is if the operation success, then I'll return. If it's failed, I'll do another operation. Is it possible and how to express it in PromiseKit?
For example, how to convert this pseudo code to PromiseKit way?
fetchData1(fromURL: "someURL") { (response, results, error) in
switch response {
case .success:
if !data.isEmpty() {
// complete
} else {
fetchData2(for: results) { (response, results, error) in
switch response {
case .success:
// complete
}
case .fail:
// complete with error
}
}
case .fail:
fetchData2(for: results) { (response, results, error) in
switch response {
case .success:
// complete
}
case .fail:
// complete with error
}
}
}
In most case, there is only one error catch and chain for the successful operation. But for my case, what I want to do is if the operation success, then I'll return. If it's failed, I'll do another operation. Is it possible and how to express it in PromiseKit?
For example, how to convert this pseudo code to PromiseKit way?