Skip to content

feat(github_search): add pagination, refresh, and race-safe concurrency - #4839

Open
GhagSagar23 wants to merge 1 commit into
felangel:masterfrom
Kryonex-Labs:feat/github-search-pagination
Open

feat(github_search): add pagination, refresh, and race-safe concurrency#4839
GhagSagar23 wants to merge 1 commit into
felangel:masterfrom
Kryonex-Labs:feat/github-search-pagination

Conversation

@GhagSagar23

Copy link
Copy Markdown

Status

IN DEVELOPMENT

Breaking Changes

NO

Description

Closes #2785.

Extends the github_search example to demonstrate search + pagination +
pull-to-refresh together with correct concurrency
— the combination the
issue asks for. Per @felangel's guidance on the issue, this builds on
github_search (which already has debounced search) rather than modifying the
flutter_infinite_list example, which is intentionally kept minimal.

Approach

A single GithubSearchBloc with one event type per concern, each using the
bloc_concurrency transformer that fits it:

Event Transformer Behavior
TextChanged debounce debounced search, resets to page 1
NextPageRequested droppable ignores new page requests while one is in flight
Refreshed restartable newest refresh wins, resets to page 1

The race the issue calls out

The reporter's core concern is a slow next-page request completing after
a refresh and corrupting pagination. Because per-handler transformers are
independent, restartable on Refreshed cancels only its own future — not a
droppable next-page already awaiting. A monotonic generation stamp on
SearchStateSuccess fixes this: _onNextPage captures the generation before
its await and drops the result if the generation moved while it was in
flight (covers new-search and same-term-refresh). Proven deterministically
by a Completer-driven test.

Changes

  • common_github_search: paged GithubClient/GithubRepository,
    accumulating SearchStateSuccess (page/hasReachedMax/generation),
    new NextPageRequested / Refreshed events, bloc_concurrency dependency.
  • flutter_github_search: infinite scroll + RefreshIndicator.
  • angular_github_search: parity (Load More / Refresh) so it keeps building.
  • Tests: common_github_search at 100% line coverage (mocked
    repository/client — no live network).
  • CI: dedicated common_github_search job enforcing min_coverage: 100.

Type of Change

  • ✨ New feature (non-breaking change which adds functionality)
  • 🛠️ Bug fix (non-breaking change which fixes an issue)
  • ❌ Breaking change (fix or feature that would cause existing functionality to change)
  • 🧹 Code refactor
  • ✅ Build configuration change
  • 📝 Documentation
  • 🗑️ Chore

…cy (felangel#2785)

Extend the github_search example with infinite-scroll pagination and
pull-to-refresh on top of the existing debounced search, using a single bloc
with per-event transformers: debounce (search), droppable (next page),
restartable (refresh). A monotonic generation stamp drops a stale next-page
result that resolves after a refresh/new search, preventing the pagination
corruption from the issue. Adds paged GithubClient/Repository, accumulating
SearchStateSuccess, and Flutter + Angular UI wiring.

Tests bring common_github_search to 100% line coverage (mocked repository/
client, no live network) and a dedicated CI job enforces min_coverage: 100.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@GhagSagar23
GhagSagar23 marked this pull request as ready for review July 16, 2026 21:57
@GhagSagar23
GhagSagar23 requested a review from felangel as a code owner July 16, 2026 21:57
@GhagSagar23

Copy link
Copy Markdown
Author

Hello @felangel, this PR has been raised using AI. I am still testing the branch throughly.

@GhagSagar23

Copy link
Copy Markdown
Author

Hey @felangel, this PR look good from my end. Can you please review this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

question: Could you please enhance your 'Infinite list' example from docs?

1 participant