executeStreamed method

  1. @protected
Future<void> executeStreamed(
  1. StreamFailureOr<DataState> function, {
  2. PreHandleData<DataState>? onDataReceived,
  3. PreHandleFailure? onFailureOccurred,
  4. bool withLoadingState = true,
  5. bool globalLoading = false,
  6. 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,
    );
  }
}