dart_debounce_throttle 2.0.0 copy "dart_debounce_throttle: ^2.0.0" to clipboard
dart_debounce_throttle: ^2.0.0 copied to clipboard

Pure Dart debounce, throttle, and rate limiting. Zero dependencies, works everywhere - Mobile, Web, Desktop, Server, CLI.

example/example.dart

import 'package:dart_debounce_throttle/dart_debounce_throttle.dart';

void main() async {
  print('=== Debounce Example ===');
  final debouncer = Debouncer(duration: Duration(milliseconds: 500));

  // Rapid calls - only the last one executes after 500ms of silence
  for (int i = 0; i < 5; i++) {
    debouncer.call(() => print('Debounced: $i'));
    await Future.delayed(Duration(milliseconds: 100));
  }

  await Future.delayed(Duration(seconds: 1));

  print('\n=== Throttle Example ===');
  final throttler = Throttler(duration: Duration(milliseconds: 500));

  // Rapid calls - first executes immediately, rest are blocked for 500ms
  for (int i = 0; i < 5; i++) {
    throttler.call(() => print('Throttled: $i'));
    await Future.delayed(Duration(milliseconds: 100));
  }

  await Future.delayed(Duration(seconds: 1));

  // Cleanup
  debouncer.dispose();
  throttler.dispose();
}
0
likes
0
points
0
downloads

Publisher

verified publisherbrewkits.dev

Weekly Downloads

Pure Dart debounce, throttle, and rate limiting. Zero dependencies, works everywhere - Mobile, Web, Desktop, Server, CLI.

Repository (GitHub)
View/report issues

Topics

#debounce #throttle #rate-limiting #async #dart

License

unknown (license)

Dependencies

meta

More

Packages that depend on dart_debounce_throttle