xiaohongshu
xiaohongshu
asyncredux-debounce-mixin
Add the Debounce mixin to wait for user input pauses before acting. Covers setting the `debounce` duration, implementing search-as-you-type, and avoiding excessive API calls during rapid input.
Full skill instructions
The Debounce mixin delays action execution until after a period of inactivity. Each new dispatch resets the timer, so the action only runs once dispatching stops for the specified duration. This is ideal for search-as-you-type functionality and avoiding excessive API calls during rapid user input.
Add the Debounce mixin to your action class:
class SearchText extends AppAction with Debounce {
final String searchTerm;
SearchText(this.searchTerm);
Future<AppState?> reduce() async {
var response = await http.get(
Uri.parse('https://example.com/?q=${Uri.encodeComponent(searchTerm)}')
);
return state.copy(searchResult: response.body);
}
}
When the user types quickly, each keystroke dispatches SearchText. The mixin delays execution, and each new dispatch resets the timer. The API call only happens once the user stops typing for the debounce period.
The default debounce period is 333 milliseconds. Override the debounce getter to customize:
class SearchText extends AppAction with Debounce {
final String searchTerm;
SearchText(this.searchTerm);
// Wait 1 second of inactivity before executing
int get debounce => 1000;
Future<AppState?> reduce() async {
var response = await http.get(
Uri.parse('https://example.com/?q=${Uri.encodeComponent(searchTerm)}')
);
return state.copy(searchResult: response.body);
}
}
By default, all instances of a debounced action share the same lock. Override lockBuilder() to create independent debounce periods for different action instances:
class SearchField extends AppAction with Debounce {
final String fieldId;
final String searchTerm;
SearchField(this.fieldId, this.searchTerm);
// Each fieldId gets its own independent debounce timer
Object? lockBuilder() => fieldId;
Future<AppState?> reduce() async {
// Search logic here
}
}
This enables multiple search fields to operate independently, each with their own debounce timer.
These two mixins serve different purposes:
| Mixin | Behavior | Best For |
|---|---|---|
| Throttle | Runs immediately on first dispatch, then blocks subsequent dispatches for the period | Rate-limiting actions that should execute right away (e.g., refresh button) |
| Debounce | Waits for quiet time, only runs after dispatches stop | Waiting for user to finish input (e.g., search-as-you-type) |
Throttle: "Execute now, then wait before allowing again" Debounce: "Wait until activity stops, then execute"
Debounce can be combined with:
CheckInternetNoDialogAbortWhenNoInternetNonReentrantFreshThrottleDebounce cannot be combined with:
RetryUnlimitedRetriesUnlimitedRetryCheckInternetOptimisticCommandOptimisticSyncOptimisticSyncWithPushServerPushURLs from the documentation:
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience