when_async 1.1.0 when_async: ^1.1.0 copied to clipboard
APIs for easy consumption of asynchronous computations
when_async #
Contains utility classes to work with asynchronous computations.
Utilities #
- [When.future] or [WhenFuture]
Usage #
A simple usage example:
import 'package:when_async/when_async.dart';
main() {
final _when = When.future<int>(
Future.delayed(
const Duration(seconds: 5),
() => 1,
),
);
_when.execute(
onLoading: () => stdout.writeln('Loading'),
onComplete: (it) => stdout.writeln('$it'),
onError: (e, s) => stdout.writeln('$e\n$s'),
onFinally: () => stdout.writeln('Finally'),
);
// OR
_when.snapshots((snapshot) {
stdout.writeln('Snapshot: ${snapshot.state}')
});
}
Features and bugs #
Please file feature requests and bugs at the issue tracker.