cubepod_async 0.1.5
cubepod_async: ^0.1.5 copied to clipboard
Asynchronous utilities and stream management for the CubePod framework.
cubepod_async #
Async utilities for CubePod — cancellation, retry, debounce, and more.
What's inside #
CancellationToken— cancel any in-flight async operation cleanlyRetryPolicy— configurable exponential backoff retry logicDebounce— delay execution until input stops changingAsyncSignal<T>— reactive wrapper for async state (loading/data/error)AsyncStreamSignal<T>— reactive wrapper for stream-based async state
Install #
dependencies:
cubepod_async: ^0.1.1
Usage #
import 'package:cubepod_async/cubepod_async.dart';
// Cancellable fetch
final token = CancellationToken();
final data = await fetchUser(token: token);
token.cancel(); // cancels if still running
// Retry with backoff
final policy = RetryPolicy(maxAttempts: 3, delay: Duration(seconds: 2));
await policy.run(() => api.uploadFile(file));
// Debounce search input
final search = Debounce<String>(delay: Duration(milliseconds: 300));
search.call(query, () => runSearch(query));
See cubepod for the full docs.