throttle function
Implementation
Rule throttle(Duration duration) {
return (dispatcher, next) {
final lastTime =
dispatcher.data[_Props.throttleLastExecutionTime] as DateTime?;
final now = DateTime.now();
final nextTime = lastTime?.add(duration);
if (nextTime == null || nextTime.compareTo(now) <= 0) {
dispatcher.data[_Props.throttleLastExecutionTime] = now;
next();
}
};
}