debounce-throttle-patterns

Implement debounce and throttle patterns for high-frequency event processing in TypeScript.

6|Updated Nov 20, 2025
One-click install
npx skills add https://github.com/daishiman/AIWorkflowOrchestrator --skill debounce-throttle-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: debounce-throttle-patterns
Source: https://github.com/daishiman/AIWorkflowOrchestrator/tree/main/.claude/skills/debounce-throttle-patterns
Command: npx skills add https://github.com/daishiman/AIWorkflowOrchestrator --skill debounce-throttle-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) and assets (resource) components.

What problem does it solve?

This Skill provides expert guidance on optimizing high-frequency events in event-driven systems using debounce and throttle patterns. It solves the problem of excessive resource consumption, unnecessary API calls, and poor UI responsiveness caused by rapid, continuous event firing.

Core Features & Use Cases

  • Debounce: Processes only the last event after a period of inactivity, ideal for search inputs, form validations, and file saves.
  • Throttle: Executes an event at a fixed interval, ensuring regular updates for scroll events, mouse movements, or progress indicators.
  • Implementation Patterns: Offers various TypeScript implementations, including leading/trailing edge, cancellable, and grouped debouncers, along with adaptive and token bucket throttlers.
  • Use Case: When building a real-time search feature, use the debounce pattern to ensure the API is only called after the user has stopped typing for a specified delay (e.g., 300ms), significantly reducing server load and improving efficiency.

Quick Start

Use the debounce-throttle-patterns skill to implement a debounced function for a search input with a 300ms delay. Provide the TypeScript template for a basic debounce function.

Frequently Asked Questions about debounce-throttle-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I reduce API calls when users type in a search input?

Debounce delays processing until the user stops typing for a set period (e.g., 300ms), ensuring the API fires only once instead of on every keystroke. This pattern minimizes server load and improves search responsiveness.

What's the difference between debounce and throttle for event handling?

Debounce waits for inactivity before executing once; throttle executes at fixed intervals during continuous events. Use debounce for form inputs and saves, throttle for scroll or resize events requiring regular updates.

How do I prevent excessive processing during scroll and resize events?

Throttle enforces a fixed interval between executions, allowing smooth UI updates without overwhelming the browser. Leading and trailing edge options control whether callbacks fire at the start or end of each interval.

Can I cancel or flush debounced and throttled operations?

Yes. The TypeScript implementations include cancellation and flush controls, letting you stop pending operations or force immediate execution when needed, essential for cleanup and testing.

What TypeScript features does this implementation use?

Type-safe APIs with leading/trailing options, max-wait debounces, grouping, and cancellation controls. The template integrates with validation and logging tools for production-ready event optimization.