v2.0.0
debounce_throttle
一個適用於 Futures、Streams 和回調的去抖動和節流工具。
75喜歡 19.9萬近 30 天下載160Pub 分數
AndroidiOSWebmacOSWindowsLinux
一個適用於 Futures、Streams 和回調的觀察者、去抖和節流工具。
以下為英文專案原文快照,最新內容請造訪 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
依賴清單 3 項
^1.0.0^2.0.0^1.0.0先依使用情境篩選,再比較專案活躍情況,最後到原始儲存庫確認使用要求。
“A repository is the most basic element of GitHub.”
GitHub Docs — About repositories ↗