0 purchases
throttling
THROTTLING DART LIBRARY #
contain "throttling" and "debouncing" classes
Using #
See a demonstration of use at dartpad.dev
Throttling example #
final thr = Throttling<void>(duration: const Duration(milliseconds: 200));
thr.throttle(() {print(' * 1');}); // print ' * 1'
await Future<void>.delayed(const Duration(milliseconds: 100));
thr.throttle(() {print(' * 2');});
await Future<void>.delayed(const Duration(milliseconds: 100));
thr.throttle(() {print(' * 3');}); // print ' * 3'
thr.close();
copied to clipboard
Debouncing example #
final deb = Debouncing<void>(duration: const Duration(milliseconds: 200));
deb.debounce(() {print(' * 1');});
await Future<void>.delayed(const Duration(milliseconds: 100));
deb.debounce(() {print(' * 2');});
await Future<void>.delayed(const Duration(milliseconds: 100));
deb.debounce(() {print(' * 3');});
await Future<void>.delayed(const Duration(milliseconds: 200));
// print ' * 3'
deb.close();
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.