From c7eb6859d1a163be3a53c8e44301e6445213220a Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Mon, 16 Mar 2020 13:30:22 -0700 Subject: [PATCH] Expand docs for isCompleted (#104) Closes #102 This field is confusing because it documents whether the backing completer has had `complete` called which doesn't necessarily correspond to when the value is available if it was completed with a `Future`. --- lib/src/cancelable_operation.dart | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/src/cancelable_operation.dart b/lib/src/cancelable_operation.dart index cbbb8d0..9fd0534 100644 --- a/lib/src/cancelable_operation.dart +++ b/lib/src/cancelable_operation.dart @@ -29,6 +29,11 @@ class CancelableOperation { /// /// [onCancel] will be called synchronously when the operation is canceled. /// It's guaranteed to only be called once. + /// + /// Calling this constructor is equivalent to creating a [CancelableCompleter] + /// and completing it with [inner]. As such, [isCompleted] is true from the + /// moment this [CancelableOperation] is created, regardless of whether + /// [inner] has completed yet or not. factory CancelableOperation.fromFuture(Future inner, {FutureOr Function() onCancel}) { var completer = CancelableCompleter(onCancel: onCancel); @@ -125,7 +130,12 @@ class CancelableOperation { /// Whether this operation has been canceled before it completed. bool get isCanceled => _completer.isCanceled; - /// Whether this operation completed before being canceled. + /// Whether the [CancelableCompleter] backing this operation has been + /// completed. + /// + /// This value being true does not imply that the [value] future has + /// completed, but merely that it is no longer possible to [cancel] the + /// operation. bool get isCompleted => _completer.isCompleted; }