throttle3<T, E, G> method

void Function(T t, E e, G g) throttle3<T, E, G>({
  1. int milliseconds = 500,
})

Implementation

void Function(T t, E e, G g) throttle3<T, E, G>({int milliseconds = 500}) {
  var isAllowed = true;
  Timer? throttleTimer;
  return (t, e, g) {
    if (!isAllowed) return;
    isAllowed = false;
    this(t,e,g);
    throttleTimer?.cancel();
    throttleTimer = Timer(Duration(milliseconds: milliseconds), () {
      isAllowed = true;
    });
  };
}