-
Notifications
You must be signed in to change notification settings - Fork 8
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
CancelableOperation.isCompleted docs are incorrect #341
Comments
It's a highly complicated state-based API.
I'd try to avoid making the last state user visible. It's true that at that point, The So the So, I'd change /// Whether the result of this operation is ready.
///
/// When ready, the [value] future is completed with the result value
/// or error, and this operation can no longer be cancelled. and /// Cancel this operation.
///
/// Has no effect if called after the result has become available
/// (when [isCompleted] becomes true).
/// If called before that, the result of the computation will be discarded
/// and the computation is ended earlier if possible.
///
/// The cancellation may take time, or even have exceptions,
/// in which case the returned future will be completed when
/// the cancellation is complete. It's still guaranteed that the
/// [value] future is not completed with a result after this
/// method has been called. (Not great, something like that). That does mean that the completer can't just fill a |
There aren't others today unless we want to leave out these details just in case there is some class that
I agree that would be the most useful. Getting there will be breaking and it's not clear to me yet how difficult it will be. |
Fixes #176 Change the `CancelableOperation.isComplete` to forward to the `_inner` completer, which is not completed until the result is available unlike `CancelableOperation.isComplete` which may lead the result when `complete` is called with a `Future` argument. Update the docs to reflect the new behavior. Keep the detail about this property indicating whether the operation can still be canceled. This detail was incorrectly stated before, but matches the new implementation. Remove details pointing to `CancelableCompleter` from the `CancelableOperation` docs. Flesh out the docs on the completer so that the distinction between the two `isComplete` getters is more clear. Remove a detail about not returning `null` from the `cancel()` doc since the non-nullable return type already makes this clear.
Fixes #176 Change the `CancelableOperation.isComplete` to forward to the `_inner` completer, which is not completed until the result is available unlike `CancelableOperation.isComplete` which may lead the result when `complete` is called with a `Future` argument. Update the docs to reflect the new behavior. Keep the detail about this property indicating whether the operation can still be canceled. This detail was incorrectly stated before, but matches the new implementation. Remove details pointing to `CancelableCompleter` from the `CancelableOperation` docs. Flesh out the docs on the completer so that the distinction between the two `isComplete` getters is more clear. Remove a detail about not returning `null` from the `cancel()` doc since the non-nullable return type already makes this clear.
Fixes dart-lang/async#176 Change the `CancelableOperation.isComplete` to forward to the `_inner` completer, which is not completed until the result is available unlike `CancelableOperation.isComplete` which may lead the result when `complete` is called with a `Future` argument. Update the docs to reflect the new behavior. Keep the detail about this property indicating whether the operation can still be canceled. This detail was incorrectly stated before, but matches the new implementation. Remove details pointing to `CancelableCompleter` from the `CancelableOperation` docs. Flesh out the docs on the completer so that the distinction between the two `isComplete` getters is more clear. Remove a detail about not returning `null` from the `cancel()` doc since the non-nullable return type already makes this clear.
The doc comment for
CancelableOperation.isCompleted
says it is tied to whether the operation can be canceled.https://github.com/dart-lang/async/blob/5737ad764bfce1ac14918944e7fb538cd674359e/lib/src/cancelable_operation.dart#L134-L139
This isn't true. The operation may still be canceled if the completer was completed with a
Future
that has not yet completed. We want definitely that behavior, otherwise theCancelableOperation.fromFuture
API makes no sense - you'd never be able to cancel such an operation at all becauseisCompleted
is true immediately in that case. I don't think we want to change the behavior ofCancelableCompleter._cancel()
.https://github.com/dart-lang/async/blob/5737ad764bfce1ac14918944e7fb538cd674359e/lib/src/cancelable_operation.dart#L34-L36
We need to decide if we want
CancelableOparation.isCompleted
to match the first or the second detail in this comment, and update the doc comment, and potentially implementation, to match.We should either update the doc to reflect current behavior:
Or, update the doc and change behavior. This would be a breaking change. I think it makes the API more useful, if potentially more confusing.
cc @lrhn
The text was updated successfully, but these errors were encountered: