runFutureQueue<T> method

Future<T?> runFutureQueue<T>(
  1. Callback<Future<T?>> callback, {
  2. Object? key,
  3. bool throwException = false,
})

Sets the key for error logs, runs the future in queue which means next future will not run unless the previous gets completed.

key: by default typeName, if null, status will be update in default key

Implementation

Future<T?> runFutureQueue<T>(
  Callback<Future<T?>> callback, {
  Object? key,
  bool throwException = false,
}) =>
    (_futureQueue.pop() ?? Future.value())
        .whenComplete(() => runErrorFuture<T>(
              _futureQueue.push(callback()),
              key: key,
              throwException: throwException,
            ));