await things

This commit is contained in:
mertalev
2024-11-08 22:04:43 -05:00
parent dbca16e352
commit 190dbb0042
2 changed files with 50 additions and 40 deletions
+3 -2
View File
@@ -10,11 +10,12 @@ class Throttler {
Throttler({required this.interval});
void run(FutureOr<void> Function() action) {
T? run<T>(T Function() action) {
if (_lastActionTime == null ||
(DateTime.now().difference(_lastActionTime!) > interval)) {
action();
final response = action();
_lastActionTime = DateTime.now();
return response;
}
}