performCancellableAsyncOperation<T> method

  1. @protected
Future<T?> performCancellableAsyncOperation<T>(
  1. Future<T> opreation
)

Performs an asynchronous operation and cancels it if the BloC is closed.

Implementation

@protected
Future<T?> performCancellableAsyncOperation<T>(Future<T> opreation) {
  if (shouldProcessEventInOrder()) {
    return opreation;
  }

  var cancellableOperation = CancelableOperation<T>.fromFuture(opreation);
  cancelableOperations.add(cancellableOperation);

  return cancellableOperation.valueOrCancellation();
}