This repository was archived by the owner on Jul 30, 2018. It is now read-only.
Open
Conversation
add support for a signal: AbortSignal property in the request options When provided, the request can be aborted by calling the AbortController#abort method, similar to the fetch API
rorticus
approved these changes
May 31, 2018
When abort is triggered, update the request Task to reject with a AbortError instead of canceling the Task. Tasks can still be canceled with the .cancel method.
dasa
reviewed
May 31, 2018
src/request/providers/xhr.ts
Outdated
| abortError = new Error('Aborted'); | ||
| abortError.name = 'AbortError'; | ||
| } | ||
| reject(new DOMException('Aborted', 'AbortError')); |
There was a problem hiding this comment.
Looks like you should use abortError here.
ycabon
reviewed
Jun 2, 2018
| timeoutReject = reject; | ||
|
|
||
| if (options.signal) { | ||
| options.signal.addEventListener('abort', () => { |
There was a problem hiding this comment.
when the request is fulfilled, the event listener should be removed.
Member
Author
There was a problem hiding this comment.
@ycabon I'm not sure there's a good place in the code to remove this event listener. Also, I'm not sure it's necessary as subsequent abort events will have no effect on a fulfilled Task.
There was a problem hiding this comment.
My concern was more for cases where the signal is reused for multiple calls, would the Task be kept in memory until the signal and controller are GCed.
| } | ||
|
|
||
| if (options.signal) { | ||
| options.signal.addEventListener('abort', () => { |
There was a problem hiding this comment.
when the request is fulfilled, the event listener should be removed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type: feature
The following has been addressed in the PR:
prettieras per the readme code style guidelinesDescription:
Note: This PR is dependent on dojo/shim#143.
Resolves #390
add support for a
signal: AbortSignalproperty in the request options. When provided, the request can be aborted by calling theAbortController#abortmethod, similar to the fetch API. When a request is aborted, thePromiseis rejected with anAbortError, if possible.