Files
umbrix/lib/core/utils/throttler.dart
problematicconsumer 28ece8fb2e Fix connection info
2024-02-13 19:59:17 +03:30

17 lines
340 B
Dart

import 'package:flutter/foundation.dart';
class Throttler {
Throttler(this.throttleFor);
final Duration throttleFor;
DateTime? _lastCall;
void call(VoidCallback callback) {
if (_lastCall == null ||
DateTime.now().difference(_lastCall!) > throttleFor) {
callback();
_lastCall = DateTime.now();
}
}
}