load<TSearchModel> method

Future<void> load<TSearchModel>([
  1. TSearchModel? searchModel
])

Implementation

Future<void> load<TSearchModel>([TSearchModel? searchModel]) async {
  if (state is AbstractListFilterableState) {
    (state as AbstractListFilterableState).searchModel = searchModel ??
        (_initialState as AbstractListFilterableState).searchModel;
  }

  await onBeforeLoad();

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

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