simple_observable 0.3.1 copy "simple_observable: ^0.3.1" to clipboard
simple_observable: ^0.3.1 copied to clipboard

outdated

Deprecated => Please use `debounce_throttle` instead.

Deprecated #

Please use debounce_throttle instead.

simple_observable #

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

  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 output #

Tick     : ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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
4
likes
30
pub points
76%
popularity

Publisher

verified publisherdefylogic.dev

Deprecated => Please use `debounce_throttle` instead.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

meta

More

Packages that depend on simple_observable