v2.0.0
debounce_throttle
Futures、Streams、コールバックと連携するデバウンサーおよびスロットル。
75いいね 20.6万30日間ダウンロード160Pub ポイント
AndroidiOSWebmacOSWindowsLinux
Futures、Streams、コールバックと連携する観察者、デバウンサー、スロットル。
^1.0.0^2.0.0^1.0.0以下は英語原文のスナップショットです。最新版は GitHub をご覧ください。
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