debounce_throttle 1.0.0 copy "debounce_throttle: ^1.0.0" to clipboard
debounce_throttle: ^1.0.0 copied to clipboard

outdated

An observer, debouncer, and throttle that works with Futures, Streams, and callbacks.

debounce_throttle #

An observable, 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.
Observable Base class for observing value changes.

Usage #

  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));

  // Wait for a fidgety button to settle.
  oldButton.onPressed(debouncer.setValue);
  debouncer.nextValue.then(buttonPressed);

  final throttle = Throttle<double>(Duration(milliseconds: 100));

  // Limit being notified of continuous sensor data.
  sensor.addListener(throttle.setValue);
  throttle.values.listen((data) => print('$data'));
61
likes
0
pub points
97%
popularity

Publisher

verified publisherdefylogic.dev

An observer, debouncer, and throttle that works with Futures, Streams, and callbacks.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

meta

More

Packages that depend on debounce_throttle