load method

Future<void> load(
  1. AbstractListLoadEvent event,
  2. Emitter<S> emit
)

Implementation

Future<void> load(AbstractListLoadEvent event, Emitter<S> emit) async {
  if (state is AbstractListFilterableState) {
    (state as AbstractListFilterableState).searchModel = event.searchModel ??
        (initialState() as AbstractListFilterableState).searchModel;
  }

  await onBeforeLoad(event, emit);

  state.resultStatus = ResultStatus.loading;
  emit(state.copyWith() as S);

  try {
    emit(await convertResultToStateAfterLoad(await resolveData()));
  } catch (e) {
    await for (final result in resolveStreamData()) {
      emit(await convertResultToStateAfterLoad(result));
      await onAfterLoad(event, emit, result);
    }
  }
}