utils/rate_limit_utils/rate_limit_utils library

Functions

debounce<T>(UnaryFunction<T> delegate, Duration delay) DebouncedFunction<T>
Returns a wrapper function that, when called with x, executes delegate(x) delay from now iff there is no other call to the wrapper between now and delay from now.
debounceNullary(void callback(), Duration delay) DebouncedNullaryFunction
Wraps debounce so that it can be called without any arguments
throttle<T>(UnaryFunction<T?> delegate, Duration interval) UnaryFunction<T>
Returns a wrapper function that, when called with x, executes delegate(x) immediately and prevents further calls to the wrapper from executing delegate until interval has elapsed.
throttleGuaranteeLast<T>(UnaryFunction<T?> delegate, Duration interval) UnaryFunction<T>
Like throttle, but if the last call to this function is throttled, it will be executed once the throttling period expires, starting a new throttling period.

Typedefs

DebouncedFunction<T> = Future Function(T argument)
DebouncedNullaryFunction = Future Function()
RateLimitStrategy<T> = UnaryFunction<T> Function(UnaryFunction<T> delegate, Duration duration)
A function that rate-limits a delegate function. Helper typedef for consumers.
UnaryFunction<T> = dynamic Function(T argument)
A function that can be throttled or debounced.