runBusyFuture<T> method

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

Sets the ViewModel 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> busyFuture,
    {Object? busyObject, bool throwException = false}) async {
  _setBusyForModelOrObject(true, busyObject: busyObject);
  try {
    var value = await runErrorFuture<T>(busyFuture,
        key: busyObject, throwException: throwException);
    return value;
  } catch (e) {
    if (throwException) rethrow;
    return Future.value();
  } finally {
    _setBusyForModelOrObject(false, busyObject: busyObject);
  }
}