https://github.com/plugfox/throttling
Throttler and debouncer in dart
https://github.com/plugfox/throttling
dart debouncer
Last synced: 4 months ago
JSON representation
Throttler and debouncer in dart
- Host: GitHub
- URL: https://github.com/plugfox/throttling
- Owner: PlugFox
- License: mit
- Created: 2019-06-10T20:07:43.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-11-22T18:39:57.000Z (over 1 year ago)
- Last Synced: 2025-03-01T02:11:37.768Z (5 months ago)
- Topics: dart, debouncer
- Language: Dart
- Homepage: https://pub.dev/packages/throttling
- Size: 59.6 KB
- Stars: 39
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# THROTTLING DART LIBRARY
##### _contain "throttling" and "debouncing" classes_
[](https://github.com/PlugFox/throttling/actions/workflows/checkout.yml)
[](https://codecov.io/gh/PlugFox/throttling)
[](https://pub.dev/packages/throttling)
[](https://opensource.org/licenses/MIT)
[](https://github.com/tenhobi/effective_dart)
[](https://github.com/PlugFox/throttling)## Using
See a demonstration of use at [dartpad.dev](https://dartpad.dev/?id=8630021e5c7ab9d27b74e86372f74c31)
### Throttling example
```dart
final thr = Throttling(duration: const Duration(milliseconds: 200));
thr.throttle(() {print(' * 1');}); // print ' * 1'
await Future.delayed(const Duration(milliseconds: 100));
thr.throttle(() {print(' * 2');});
await Future.delayed(const Duration(milliseconds: 100));
thr.throttle(() {print(' * 3');}); // print ' * 3'
thr.close();
```### Debouncing example
```dart
final deb = Debouncing(duration: const Duration(milliseconds: 200));
deb.debounce(() {print(' * 1');});
await Future.delayed(const Duration(milliseconds: 100));
deb.debounce(() {print(' * 2');});
await Future.delayed(const Duration(milliseconds: 100));
deb.debounce(() {print(' * 3');});
await Future.delayed(const Duration(milliseconds: 200));
// print ' * 3'
deb.close();
```