How do I cancel a promise that has been neither fulfilled or rejected yet?
The documentation for PromiseKit talks about cancelling a promise, but I can't find a specific example of how to do this.
Given:
currentOperation = client.load(skip: skip, query: nil)
currentOperation!.then { (items) in
self.processItems(items: items, skip: skip, query: query)
}.catch { (error) in
print("failed to load items - just retrying")
self.loadIfNeeded(skip: skip, query: query, onlyInStock: onlyInStock)
}
If the query changes (user enters some text in the search bar) I want to cancel and discard the currentOperation
, starting a new promise.