Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/plugfox/throttling
Throttler and debouncer in dart
https://github.com/plugfox/throttling
dart debouncer
Last synced: 11 days 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 (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-11-22T18:39:57.000Z (12 months ago)
- Last Synced: 2024-10-12T05:43:04.470Z (27 days ago)
- Topics: dart, debouncer
- Language: Dart
- Homepage: https://pub.dev/packages/throttling
- Size: 59.6 KB
- Stars: 38
- 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_
[![Actions Status](https://github.com/PlugFox/throttling/actions/workflows/checkout.yml/badge.svg)](https://github.com/PlugFox/throttling/actions/workflows/checkout.yml)
[![Coverage](https://codecov.io/gh/PlugFox/throttling/branch/master/graph/badge.svg)](https://codecov.io/gh/PlugFox/throttling)
[![Pub](https://img.shields.io/pub/v/throttling.svg)](https://pub.dev/packages/throttling)
[![License: MIT](https://img.shields.io/badge/license-MIT-purple.svg)](https://opensource.org/licenses/MIT)
[![Effective Dart](https://img.shields.io/badge/style-effective_dart-40c4ff.svg)](https://github.com/tenhobi/effective_dart)
[![Star on Github](https://img.shields.io/github/stars/plugfox/throttling.svg?style=flat&logo=github&colorB=deeppink&label=stars)](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();
```