runBusyFuture<T> method

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

Sets the Controller to busy, runs the future and then sets it to not busy when complete.

rethrows Exception after setting busy to false for object or class

Implementation

Future<T?> runBusyFuture<T>(
  Future<T?> future, {
  Object? key,
  bool throwException = false,
}) async {
  final _key = key ?? typeName;
  setBusyFor(_key, true);
  try {
    final value = await runErrorFuture<T>(
      future,
      key: key,
      throwException: throwException,
    );
    setBusyFor(_key, false);
    return value;
  } catch (e) {
    setBusyFor(_key, false);
    if (throwException) rethrow;
    return Future.value();
  }
}