chetan2921/flo/riverpod-cancel
Claude Code and agent skill by chetan2921/flo
- community
Checking that the SKILL.md file is still in the repository.
Cancel or debounce Riverpod async requests with ref.onDispose; cancel when user leaves the page, debounce rapid refreshes. Use when the user asks about cancelling requests, debouncing, or cleaning up when a provider is disposed.
Install
npx vskill@latest install chetan2921/flo/riverpod-cancelSKILL.md
The same SKILL.md was published earlier as majiayu000/claude-skill-registry/riverpod-cancel.
Riverpod — Cancelling and debouncing requests
Instructions
Use ref.onDispose together with auto-dispose (or ref.watch) to cancel in-flight requests when the user leaves the page, or to debounce rapid refreshes.
Cancelling when leaving the page
Ensure the provider is auto-dispose. When the user navigates away, the provider loses its listeners and is disposed; ref.onDispose runs. In that callback, cancel the request (e.g. close the HTTP client used for the request).
Example pattern: create an http.Client() in the provider, pass it to your fetch logic, and call ref.onDispose(client.close). When the provider is disposed, the client closes and the request is cancelled. Exact API depends on your HTTP package.
Debouncing refreshes
If the user triggers refresh multiple times quickly, you can delay the actual request until they stop (e.g. 500ms). Pattern:
- In the provider, set a flag (e.g.
didDispose = false) and ref.onDispose(() => didDispose = true). - await Future.delayed(duration).
- If didDispose is true, the user triggered another refresh during the delay; throw to abort (Riverpod catches and ignores). Otherwise create the client, register onDispose(client.close), and run the request.
So: delay first, then create client and run request; disposal during the delay aborts, disposal after creates client cancels the request.
Reusable extension
You can implement an extension on Ref that returns a debounced/cancellable client:
- Use onDispose to set a "cancelled" flag.
- Wait for the debounce duration; if disposed, throw.
- Create the client, onDispose(client.close), return the client.
Use this extension in your activity/provider so all call sites get debounce + cancel behavior. See the official Riverpod "cancel" how-to for a full extension example.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryChecking.github/skills/riverpod-cancel/SKILL.md
Popularity
- 7-day trend score
- 5
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/chetan2921/flo/riverpod-cancel)