execute method

Future<void> execute()

Starts the execution. Has no effect if already in progress.

Implementation

Future<void> execute() async {
  if (state is AsyncLoading<T>) return;
  emit(const AsyncLoading());
  try {
    final result = await run();
    emit(AsyncSuccess<T>(result));
  } catch (e) {
    emit(AsyncFailure<T>(e));
  }
}