Skip to content

v2.4.6: The Honest API & Riverpod Edition

Latest

Choose a tag to compare

@vietnguyentuan2019 vietnguyentuan2019 released this 03 May 09:25
· 2 commits to main since this release
1c64e0b

2.4.6: The Honest API & Riverpod Edition

This is a massive release that brings architectural honesty, a brand-new official Riverpod package, and a monumental increase in testing rigor.

🚀 New: Honest API — No Silent Failures

ThrottlerResult — Know if the operation actually ran

ConcurrentAsyncThrottler.call() now returns Future<ThrottlerResult> instead of Future<void>.
This prevents a class of silent-failure bugs where dropped operations appeared to succeed.

// ❌ Before: silent failure — showSuccessDialog() fires even if order was never submitted
await throttler.call(() async => submitOrder(orderId));
showSuccessDialog();

// ✅ After: exhaustive handling required at compile time
(await throttler.call(() async => submitOrder(orderId))).when(
  onExecuted: () => showSuccessDialog(),
  onDropped:  () => showError('Server busy — please try again.'),
);

DebounceResult — Exhaustive pattern matching

callWithResult() existed before; now DebounceResult gains when() and fluent helpers:

(await debouncer.callWithResult(() => searchApi(query)))
  .whenSuccess((data) => setState(() => _results = data))
  .whenCancelled(() => setState(() => _loading = false));

CancellationToken support

ConcurrentAsyncThrottler.callWithToken() allows cooperative cancellation of in-flight async work.


🎉 New Official Package: flutter_debounce_throttle_riverpod

We have released a dedicated integration for Riverpod! EventLimiterController ties debounce/throttle timers to a Riverpod Ref lifecycle — zero boilerplate, auto-cleanup on provider dispose.

dependencies:
  flutter_debounce_throttle_riverpod: ^1.0.0

🛡️ Unprecedented Testing Rigor

  • Test suite expanded massively: Jumped from ~140 tests to 570+ tests, reaching 98% coverage.
  • New Test Categories: Added PerformanceStressTest, SystemStressTest, and SecurityTest to guarantee behavior under extreme loads.
  • Hooks Coverage: Hooks tests expanded from 18 to 63 to ensure absolute stability.

🎨 Documentation & Demo Overhaul

  • New Demo Apps: The example app has been completely rebuilt with 5+ interactive scenarios.
  • Visual Documentation: README.md now features a beautiful 6-grid GIF layout demonstrating (Search, Throttle, Submit, Concurrency Replace, Hooks, and Riverpod).
  • Recording Guide: Added RECORDING_GUIDE.md and automated scripts for generating documentation assets.

🔧 Bug Fixes & CI Improvements

  • Async Race Conditions Resolved: Fixed lock race conditions in AsyncThrottler and AsyncDebouncer where timeout callbacks could improperly unlock state for subsequent valid executions.
  • Enqueue Overflow Fix: ConcurrentAsyncThrottler previously threw an unhandled exception on overflow; it now gracefully resolves with ThrottlerResult.dropped().
  • CI/CD Stability: Resolved persistent melos bootstrap failures, added dependency_overrides for local example resolution, and migrated to Node.js 20 compatible GitHub Actions.
  • Cleanup: reset() and dispose() now correctly drain all pending completers with ThrottlerResult.dropped() instead of leaving awaiting callers permanently suspended.