flutter_execution_utilities library
A collection of execution control utilities for Flutter and Dart, including debounce, throttle, memoization, retry mechanisms, and more
Classes
-
Batcher<
T> - A utility class that batches calls to func within a specified duration, aggregating arguments into a list.
-
CircuitBreaker<
T> - A Circuit Breaker implementation to prevent repeated failures by wrapping an asynchronous function and controlling its execution based on the success or failure rate.
Enums
- CircuitState
- Represents the state of the circuit breaker.
Functions
-
debounce<
T> (void action(T args), Duration delay, {bool leading = false}) → void Function(T) -
Creates a debounced function that delays invoking
action
until afterdelay
has passed since the last time the debounced function was called. -
delayExecution(
Function func, Duration delay) → Function -
Returns a function that delays the execution of
func
bydelay
duration. -
memoize(
Function func) → Function -
Returns a memoized version of
func
. -
rateLimiter(
Function func, int maxCalls, Duration duration) → Function -
Creates a rate-limited version of
func
that allows onlymaxCalls
executions perduration
. -
retry<
T> (Future< T> func(), {int maxRetries = 3, Duration? delay, bool retryIf(Object error)?}) → Future<T> -
Retries the asynchronous operation
func
up tomaxRetries
times with an optionaldelay
between attempts. -
throttle<
T> (void action(T args), Duration delay, {bool leading = true, bool trailing = false}) → void Function(T) -
Creates a throttled function that only invokes
action
at most once everydelay
duration.