setLoadingStateHandler method

Stream<Result<T>> setLoadingStateHandler(
  1. RxBlocBase bloc, {
  2. bool shareReplay = true,
})

Handle ResultLoading states from stream.

Once the states are being handled they sink to RxBlocBase.loadingState. Converts the stream to broadcast one based on shareReplay.

In case you need to handle error states along with the loading state, use setResultStateHandler instead.

Implementation

Stream<Result<T>> setLoadingStateHandler(
  RxBlocBase bloc, {
  bool shareReplay = true,
}) =>
    doOnData(
      (event) => bloc._loadingBloc.setResult(
        result: event,
      ),
    ).asSharedStream(shareReplay: shareReplay);