Skip to content

Commit

Permalink
Expand docs for isCompleted (#104)
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
natebosch authored Mar 16, 2020
1 parent 06f4a1d commit c7eb685
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/src/cancelable_operation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ class CancelableOperation<T> {
///
/// [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<T> inner,
{FutureOr Function() onCancel}) {
var completer = CancelableCompleter<T>(onCancel: onCancel);
Expand Down Expand Up @@ -125,7 +130,12 @@ class CancelableOperation<T> {
/// 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;
}

Expand Down

0 comments on commit c7eb685

Please sign in to comment.