async_track 0.2.0 async_track: ^0.2.0 copied to clipboard
Track asynchronous events in Dart.
async_track #
Provides a mechanism for tracking asynchronous events in Dart.
This package is experimental and subject to change. It currently only has knowledge of microtasks and timers, and ignores other forms of asynchronous events DOM access, network events, file I/O.
Usage #
You can use track asynchronous events once or continuously.
runTracked #
Future/*<E>*/ runTracked/*<E>*/(/*=E*/ action())
runs action
within
a Zone, and returns a Future when all asynchronous
events started by action
(or started by other events) complete.
For example, waiting for some tasks to complete:
await runTracked(() {
// Any of these could use 'scheduleMicrotask' to schedule work.
doTask1();
doTask2();
doTask3();
});
AsyncTracker #
For continuous tracking, you can use AsyncTracker
, which reports
progress of asynchronous events continuously. See async_track.dart
.
How it works #
Uses the Dart Zone API to create an execution context where a function call and all of it's associated calls and asynchronous tasks are associated with that zone.