Implementation
Future<void> loadMore() async {
if (state.hasReachedMax || state.isLoading) return;
final offset = state.filteredComponents.length;
final result = state.selectedType != null
? await repository.getByType(state.selectedType!,
offset: offset, limit: _pageSize)
: state.searchQuery.isNotEmpty
? await repository.search(state.searchQuery,
offset: offset, limit: _pageSize)
: await repository.getAll(offset: offset, limit: _pageSize);
result.fold(
(error) => emit(state.copyWith(error: error)),
(components) => emit(state.copyWith(
filteredComponents: [...state.filteredComponents, ...components],
hasReachedMax: components.length < _pageSize,
)),
);
}