throttle2 method

void Function(dynamic value1, dynamic value2) throttle2({
  1. int milliseconds = 500,
})

Implementation

void Function(dynamic value1,dynamic value2) throttle2({int milliseconds = 500}) {
  var isAllowed = true;
  Timer? throttleTimer;
  return (value1,value2,) {
    if (!isAllowed) return;
    isAllowed = false;
    this();
    throttleTimer?.cancel();
    throttleTimer = Timer(Duration(milliseconds: milliseconds), () {
      isAllowed = true;
    });
  };
}