loadAll method

Future<void> loadAll()

Implementation

Future<void> loadAll() async {
  emit(state.copyWith(
    isLoading: true,
    error: null,
    filteredComponents: [],
    hasReachedMax: false,
  ));

  final result = await repository.getAll(offset: 0, limit: _pageSize);

  result.fold(
    (error) => emit(state.copyWith(isLoading: false, error: error)),
    (components) => emit(state.copyWith(
      isLoading: false,
      allComponents: components,
      filteredComponents: components,
      hasReachedMax: components.length < _pageSize,
    )),
  );
}