execute method

Future<void> execute(
  1. Future<T> operation()
)

Execute an async operation and handle states automatically.

Stores the operation for later refresh calls.

Implementation

Future<void> execute(Future<T> Function() operation) async {
  _lastOperation = operation;
  emitLoading();
  try {
    final data = await operation();
    emitData(data);
  } catch (e, stack) {
    emitError(e, stack);
  }
}