Recipes
Shape input with Throttle
Choose leading, trailing, or leading-and-trailing admission for a keyed command stream.
v0.1.0-dev.2Intermediateusecase_forge
Open source reference ↗Shape input with Throttle
Throttle controls how often related Commands leave admission. It does not limit how many already admitted Executions may run.
Choose the mode
| Mode | First Command | Latest Command during window | Use when |
|---|---|---|---|
leading | admitted immediately | rejected | immediate response matters |
trailing | retained until the window ends | replaces the retained candidate | only the latest value matters |
leadingAndTrailing | admitted immediately | latest is retained for the end | immediate and final values both matter |
dart
registerCommand<RefreshMetrics>(
_refresh,
instructions: UseCaseInstructionOverrides(
input: UseCaseInputInstructionOverrides(
throttle: UseCaseThrottleInstructions(
duration: const Duration(seconds: 1),
mode: UseCaseThrottleMode.leadingAndTrailing,
),
),
),
);
RefreshMetrics.executionKey must identify the dashboard or resource whose refreshes belong to one lane. Commands with another exact type or key use independent windows.
Observe rejection explicitly
Intermediate Commands are reported to onCommandRejected as throttled; they never become terminal history entries. If every intent must eventually execute, throttle is the wrong Instruction—use sequential processing instead.