executeStreamed method
Future<void>
executeStreamed(
- StreamFailureOr<
T> function, { - PreHandleData<
T> ? onDataReceived, - PreHandleFailure? onFailureOccurred,
- bool withLoadingState = true,
- bool globalLoading = false,
- bool globalFailure = true,
inherited
Executes received stream function
with additional parameters to control if loading state should be set while executing function
by providing withLoadingState
param.
Usage is the same as the execute method with the main difference in number of function
results (and consequently number of state updates) as it is a stream of data
Implementation
@protected
// ignore: avoid-redundant-async
Future<void> executeStreamed(
StreamFailureOr<DataState> function, {
PreHandleData<DataState>? onDataReceived,
PreHandleFailure? onFailureOccurred,
bool withLoadingState = true,
bool globalLoading = false,
bool globalFailure = true,
}) async {
_setLoading(withLoadingState, globalLoading);
await for (final result in function) {
_handleResult(
result,
onDataReceived,
onFailureOccurred,
withLoadingState,
globalLoading,
globalFailure,
);
}
}