load method

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

Implementation

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

  await onBeforeLoad();

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

  try {
    emit(convertResultToState(await resolveData()));
  } catch (e) {
    await emit.forEach<Result>(
      resolveStreamData(),
      onData: (result) => convertResultToState(result),
    );
  }
}