execute method
Executes an asynchronous operation and updates the state accordingly.
Implementation
Future<void> execute(Future<T> Function() operation) async {
throwIfDisposed('execute');
return MinixErrorHandler.safeExecuteAsync(() async {
_state.value = AsyncState.loading;
_error.value = null;
try {
final result = await operation();
if (!isDisposed) {
_data.value = result;
_state.value = AsyncState.success;
}
} catch (e) {
if (!isDisposed) {
_error.value = e.toString();
_state.value = AsyncState.error;
}
}
}, context: 'AsyncObservable.execute');
}