Skip to content
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

Support query.cancel() #1003

Merged
merged 7 commits into from
Nov 23, 2019
Merged

Support query.cancel() #1003

merged 7 commits into from
Nov 23, 2019

Conversation

dplewis
Copy link
Member

@dplewis dplewis commented Nov 20, 2019

Closes: #997

Taken from Android API cancel

Can be improved in the future.

@codecov
Copy link

codecov bot commented Nov 20, 2019

Codecov Report

Merging #1003 into master will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1003      +/-   ##
==========================================
+ Coverage   91.91%   91.94%   +0.02%     
==========================================
  Files          53       53              
  Lines        5098     5114      +16     
  Branches     1145     1146       +1     
==========================================
+ Hits         4686     4702      +16     
  Misses        412      412
Impacted Files Coverage Δ
src/ParseQuery.js 96.14% <100%> (+0.1%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 566f29a...e2fd677. Read the comment docs.

@dplewis
Copy link
Member Author

dplewis commented Nov 20, 2019

@acinader @davimacedo This is hard to test in a node environment as the node-xmlhttprequest package (hasn't been published in 4 years) is lacking proper support for abort. i.e. every open connection calls abort when opened. This isn’t a problem for Parse.File cancel since it doesn’t use that package.

Canceling queries is tricky. The RESTController does a few promises like installationId and currentUser before the request. The requestTask might not be set when cancel is called. I added an onchange event to know when the request started. We could move this to a query.onStart or something like that.

It should work in browser though.

@dplewis
Copy link
Member Author

dplewis commented Nov 21, 2019

@acinader @davimacedo I updated my comment. Thoughts?

@dplewis dplewis requested a review from acinader November 22, 2019 23:36
Copy link
Contributor

@acinader acinader left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you think we should release this, given its limitations, is ok with me.

@dplewis dplewis merged commit 728c43e into master Nov 23, 2019
@dplewis dplewis deleted the query-cancel branch November 23, 2019 00:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Terminate a query, like in Axios
2 participants