v2.0.0
debounce_throttle
A debouncer and throttle that works with Futures, Streams, and callbacks.
75Likes 205.8K30-day downloads160Pub points
AndroidiOSWebmacOSWindowsLinux
An observer, debouncer, and throttle that works with Futures, Streams, and callbacks.
^1.0.0^2.0.0^1.0.0English project snapshot. Visit GitHub for the latest content.
A debouncer and throttle that works with Future, Stream, and callbacks.
| Class | Purpose |
|---|---|
Debouncer |
Wait for changes to stop before notifying. |
Throttle |
Notifies once per Duration for a value that keeps changing. |
final debouncer = Debouncer<String>(Duration(milliseconds: 200));
// Run a search whenever the user pauses while typing.
textEditingController.addListener(() => debouncer.value = textEditingController.text);
debouncer.values.listen((search) => submitSearch(search));
final throttle = Throttle<double>(Duration(milliseconds: 100));
// Limit being notified of continuous sensor data.
sensor.addListener(throttle.setValue);
throttle.values.listen((data) => print('$data'));
example/main.dart outputTick : ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Changed : ----------- - -- - - - -- - - - - - - - --- - - - - - - - - - - - -- - - - - - - -- - -- --- - - - - - - - - -
Debounced: D D D D D D D D D D D D D D D D D D D D D D D D D D D
Throttled: T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T