Mobile/lib/Components/utils/debounce.dart
2024-11-18 19:35:01 +04:00

17 lines
339 B
Dart

import 'dart:async';
import 'dart:ui';
class Debouce {
factory Debouce() => _instance;
Debouce._();
static final Debouce _instance = Debouce._();
static Timer? _timer;
static void run(VoidCallback action, {Duration delay = const Duration(milliseconds: 500),}) {
_timer?.cancel();
_timer = Timer(delay, action);
}
}