throttle 0.1.0 throttle: ^0.1.0 copied to clipboard
A stream transformer for slowing down (buffering) events that may happen frequently
Throttle #
A stream transformer for slowing down (buffering) events that may happen frequently
Example #
import 'dart:async';
import 'package:throttle/throttle.dart';
main() {
var controller = new StreamController();
var transformer = new Throttle(new Duration(seconds: 1));
var throttled = controller.stream.transform(transformer);
// print the throttled events as they arrive
throttled.listen(print);
// print some events as fast as possible
for (var i = 0; i < 10; i++) {
controller.add(i);
}
}