New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do I cancel a promise? #52
Comments
Hi @dinghaoz, could you by chance throttle requests on the UI level? func textViewDidChange(_ textView: UITextView) {
NSObject.cancelPreviousPerformRequests(withTarget: self, selector: #selector(autocomplete(_:)), object: textView)
perform(#selector(autocomplete(_:)), with: textView, afterDelay: 0.5)
}
@objc
func autocomplete(_ textView: UITextView) {
// ...
} |
Thanks for the quick reply @shoumikhin, and sorry for the confusion. Think about another case where there are many depending network requests chained together with the promises pattern inside a UIViewController, and then when the user tap the back button of the UIViewController, I would like to cancel all of them, including those haven't been sent out yet, with one cancellation method on some object. Does promises supports that? or do I use it in a wrong way? |
There's some ongoing work to add convenient cancellation to Promises. |
Thanks @shoumikhin |
A use case is autocomplete. When user types, I send out a request to query the completion info but if the user types fast enough, I want to cancel previous sent request before sending the new one.
Thanks
The text was updated successfully, but these errors were encountered: