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

Add cancellation token package #2

Merged
merged 4 commits into from
May 24, 2017
Merged

Conversation

jeskew
Copy link
Contributor

@jeskew jeskew commented Apr 10, 2017

@jeskew jeskew force-pushed the feature/cancellation-token branch from f24e0df to a2b6999 Compare May 1, 2017 08:41
@jeskew jeskew force-pushed the feature/cancellation-token branch from a2b6999 to 7f7ed81 Compare May 23, 2017 19:03
@jeskew jeskew requested review from awood45 and chrisradek May 23, 2017 19:36
Copy link
Member

@awood45 awood45 left a comment

Choose a reason for hiding this comment

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

Generally looks good, but with the very large caveat that this is totally undocumented, so I'm not sure what problem this is trying to solve.

@jeskew jeskew force-pushed the feature/cancellation-token branch from a5c1dc6 to 028ee7d Compare May 23, 2017 22:48
* Creates a new Token object linked to this TokenSource (i.e., one that
* will signal cancellation when this source has been cancelled).
*/
get token(): Token {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why use a getter here instead of a method? It seems a little weird here because the following is not intuitive:

const tokenSource = new TokenSource();
// expect next line to be 'true' but instead get 'false'
tokenSource.token === tokenSource.token;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. I'll switch this to a method.

/**
* Alias of this.cancellable
*/
get canBeCancelled(): boolean {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need both Token.cancellable and Token.canBeCancelled fields if they return the same thing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought canBeCancelled was more accurate but a bit verbose, but it's not necessary.

/**
* Alias of this.canceled
*/
get isCancellationRequested(): boolean {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment about using aliased fields.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will remove.

Copy link
Contributor

@chrisradek chrisradek left a comment

Choose a reason for hiding this comment

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

Approved assuming docs get added back for getToken!

@@ -12,27 +12,20 @@ export class Token {
* Whether the associated operation may be cancelled at some point in the
* future.
*/
public readonly cancellable: boolean;
public readonly canBeCancelled: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

Optional: I actually liked cancellable, but it doesn't really matter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed.

@@ -50,6 +42,10 @@ export class TokenSource {
}
}

getToken(): Token {
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: The docs for token should be moved here as well.

@chrisradek
Copy link
Contributor

:shipit:

@jeskew jeskew merged commit 08f723d into master May 24, 2017
@jeskew jeskew deleted the feature/cancellation-token branch May 24, 2017 18:06
trivikr referenced this pull request in trivikr/aws-sdk-js-v3 Dec 10, 2018
@lock
Copy link

lock bot commented Sep 27, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked as resolved and limited conversation to collaborators Sep 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants