ff_timed_operations 1.0.2
ff_timed_operations: ^1.0.2 copied to clipboard
Tools to help with timed operations such as Debounce Throttle operations.
Timed Operations #

Timed Operations provides better handling of timed operations such as Debounce Throttle operations.
Additionally, it provides optional callbacks to handle different states and outcomes, such as errors, waiting states, null or empty data, and successful completion of the operation.
Features #
- Debounce (async/sync)
- Throttle (async/sync)
- Extensive handling (optional)
Usage #
Throttle.sync() #
Throttles a synchronous operation by preventing it from being executed more
frequently than the specified throttle duration, and executes a success
callback with the result of the operation.
Throttle.sync<int>(
callId: 'example',
operation: () => 1 + 1,
onThrottle: () => print('Operation is throttled'),
onNull: () => print('Operation returned null'),
onEmpty: () => print('Operation returned an empty iterable or map'),
onSuccess: (result) => print('Operation result: $result'),
throttle: const Duration(milliseconds: 500),
);
Throttle.async() #
/// Throttles the execution of an asynchronous operation and handles its result or errors
/// based on the given callback functions. The callId parameter is used to identify
/// the operation and avoid concurrent executions. The operation parameter is the
/// asynchronous operation to be throttled, and duration is the duration of the
/// throttling period.
await Throttle.async<int>(
callId: 'example',
operation: () async {
// perform some async operation
await Future.value(100);
},
onThrottle: () => print('Operation is throttled'),
onNull: () => print('Operation returned null'),
onEmpty: () => print('Operation returned an empty iterable or map'),
onSuccess: (result) => print('Operation result: $result'),
duration: const Duration(milliseconds: 500),
timeout: const Duration(seconds: 5),
);
❤️ Support Flutter Focus #
Need Mobile, Web or Video marketing services? 📱 🌐 📹 #
Flutter Focus offers bespoke services in multimedia storytelling by mixing Mobile, Web and Video.