async_track 0.2.0

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 11

async_track

Build Status Pub

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.

Changelog

0.2.0

  • Added AsyncError object
  • Added onError callback to runTracked
  • Added onError stream to AsyncTracker
  • Added useLongStackTraces as a parameter to new AsyncTracker

0.1.0

  • Initial commit

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  async_track: "^0.2.0"

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:async_track/async_track.dart';
        
Version Uploaded Documentation Archive
0.2.0 Nov 16, 2016 Go to the documentation of async_track 0.2.0 Download async_track 0.2.0 archive
0.1.0 Sep 30, 2016 Go to the documentation of async_track 0.1.0 Download async_track 0.1.0 archive

Analysis

We analyzed this package on Apr 23, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.49.0
  • pana: 0.10.6

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
0 / 100
Health:
Code health derived from static analysis. [more]
0 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
54 / 100
Overall score:
Weighted score of the above. [more]
11
Learn more about scoring.

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:async_track/async_track.dart.

Suggestions

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 5 errors 45 hints.

    Strong-mode analysis of lib/async_track.dart failed with the following error:

    line: 336 col: 48
    The return type 'void' isn't a 'R', as defined by the method 'runGuarded'.

  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Maintain an example.

    Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use async_track.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
meta >=1.0.4 <2.0.0 1.1.2
stack_trace >=1.7.0 <2.0.0 1.9.2
Transitive dependencies
path 1.5.1
Dev dependencies
dart_style
test