How to cancel a promise that has not yet been fulfilled or rejected?
The documentation for PromiseKit talks about breaking a promise, but I cannot find a concrete example of how to do this.
Considering:
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 (the user enters some text in the search bar), I want to cancel and cancel the currentOperation , starting a new promise.
source share