This repository has been archived by the owner on Oct 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 50
Conversation
This file contains 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
A prior change made it so that a `.then` on a `CancelableOperation` would call the `onValue`/`onError` callback even if the returned operation was cancelled beteen the time of the `then` and the time the original operation completed. The result would not show up in the cancelled operation, but the callbacks would run. This change blocks calling the callbacks if the returned operation has been cancelled.
`fail` has a return type of `Never`.
Towards #210 Once combined with `Completer.completeOperation` this signature adds significant flexibility for chaining Cancelable work following other async work. Move the existing `.then` operation to `.thenOperation` since the latter is more general.
natebosch
commented
Mar 18, 2022
lrhn
approved these changes
Mar 18, 2022
lib/src/cancelable_operation.dart
Outdated
} | ||
|
||
/// Creates a new cancelable operation to be completed | ||
/// when this operation completes or is cancelled. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a long first paragraph (guildeline is one line).
Not that I can find a good shorter version, though.
lib/src/cancelable_operation.dart
Outdated
/// when this operation completes or is cancelled. | ||
/// | ||
/// The [onValue] and [onError] callbacks behave in the same way as | ||
/// for [Future.then], and the result of those callbacks is used to complete |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same way ... well, almost. Future.then
is a little clever. If the onError
handler throws the same error object that it got in, it considers it a rethrow and uses the old stack instead of the new.
I don't actually think that's valuable here, but maybe change "in the same way as" to "similarly to".
mosuem
pushed a commit
to dart-lang/core
that referenced
this pull request
Oct 14, 2024
Towards dart-lang/async#210 Once combined with `Completer.completeOperation` this signature adds significant flexibility for chaining Cancelable work following other async work. Move the existing `.then` implementation to `.thenOperation` since the latter is more general. Co-authored-by: Lasse R.H. Nielsen <lrn@google.com>
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.
Towards dart-lang/core#351
Once combined with
Completer.completeOperation
this signature addssignificant flexibility for chaining Cancelable work following other
async work.
Move the existing
.then
implementation to.thenOperation
since the latteris more general.