Skip to content
Agentmart
Submit a tool

riverpod-cancel

Cancel or debounce Riverpod async requests with ref.onDispose; cancel when user leaves the page, debounce rapid refreshes.

Skill by serverpod

IndexedBSD-3-Clause★ 10
Write a review

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/serverpod-riverpod-cancel

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

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.

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/riverpod-cancel

What's inside

Skill name
riverpod-cancel
Description
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.
License
BSD-3-Clause
Instructions
33 lines in SKILL.md · view on GitHub

Files (1)

  • SKILL.md

SKILL.md (first lines)

# 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:

1. In the provider, set a flag (e.g. `didDispose = false`) and **ref.onDispose(() => didDispose = true)**.
2. **await Future.delayed(duration)**.
3. 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.

From serverpod/skills-registry, BSD-3-Clause.

More from serverpod/skills-registry

Signals

Stars
10
Forks
0
Open issues
0
Last commit (this folder)
Mar 7, 2026 (7 months ago)

From GitHub (fetched Oct 24, 2026).

Details

License
BSD-3-Clause
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from serverpod

Cite this page

riverpod-cancel skill. Agent Mart. https://agentmart.dev/skills/serverpod-riverpod-cancel (last updated 2026-10-24)