philiprehberger_debounce 0.1.1 copy "philiprehberger_debounce: ^0.1.1" to clipboard
philiprehberger_debounce: ^0.1.1 copied to clipboard

Debounce and throttle utilities with Stream transformers and cancellation

example/example.dart

import 'package:philiprehberger_debounce/debounce.dart';

void main() async {
  // Debouncer
  final debouncer = Debouncer(delay: Duration(milliseconds: 300));
  debouncer.call(() => print('Only this one runs'));
  debouncer.call(() => print('Only this one runs'));
  debouncer.call(() => print('Debounced!'));

  // Wait for debounce to fire
  await Future<void>.delayed(Duration(milliseconds: 500));

  // Throttler
  final throttler = Throttler(interval: Duration(seconds: 1));
  throttler.call(() => print('Throttled call 1'));
  throttler.call(() => print('Throttled call 2 - skipped'));

  // Stream debounce
  final stream = Stream.fromIterable([1, 2, 3, 4, 5]);
  await stream.throttle(Duration(milliseconds: 100)).forEach(print);
}
0
likes
160
points
--
downloads

Documentation

API reference

Publisher

verified publisherphiliprehberger.com

Debounce and throttle utilities with Stream transformers and cancellation

Homepage
Repository (GitHub)
View/report issues

License

MIT (license)

More

Packages that depend on philiprehberger_debounce