execute method
Future<void>
execute({
- VoidCallback? onLoading,
- VoidValueCallback<
T> ? onComplete, - VoidErrorCallback? onError,
- VoidCallback? onFinally,
override
Asynchronously executes a computation once with listener callbacks in parameters for the asynchronous computation that may fail into something that is safe to read.
This is useful to avoid having to do a tedious try/catch/then
.
This only does the asynchronous future computation once and returns the same future's result in subsequent calls. To refresh/redo an asynchronous computation which has already been computed, use refresh.
Implementation
@override
Future<void> execute({
final VoidCallback? onLoading,
final VoidValueCallback<T>? onComplete,
final VoidErrorCallback? onError,
final VoidCallback? onFinally,
}) async {
onLoading?.call();
try {
final _response = await asyncValue;
onComplete?.call(_response);
} catch (e, s) {
onError?.call(e, s);
} finally {
onFinally?.call();
}
}