async 1.11.3

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 81

Contains utility classes in the style of dart:async to work with asynchronous computations.

Zipping streams

The StreamZip class can combine several streams of events into a single stream of tuples of events.

Results

The package introduces a Result class that can hold either a value or an error. It allows capturing an asynchronous computation which can give either a value or an error, into an asynchronous computation that always gives a Result value, where errors can be treated as data. It also allows releasing the Result back into an asynchronous computation.

1.11.3

  • Fix strong-mode warning against the signature of Future.then

1.11.1

  • Fix new strong-mode warnings introduced in Dart 1.17.0.

1.11.0

  • Add a typedStreamTransformer() function. This wraps an untyped StreamTransformer with the correct type parameters, and asserts the types of events as they're emitted from the transformed stream.

  • Add a StreamSinkTransformer.typed() static method. This wraps an untyped StreamSinkTransformer with the correct type parameters, and asserts the types of arguments passed in to the resulting sink.

1.10.0

  • Add DelegatingFuture.typed(), DelegatingStreamSubscription.typed(), DelegatingStreamConsumer.typed(), DelegatingSink.typed(), DelegatingEventSink.typed(), and DelegatingStreamSink.typed() static methods. These wrap untyped instances of these classes with the correct type parameter, and assert the types of values as they're accessed.

  • Add a DelegatingStream class. This is behaviorally identical to StreamView from dart:async, but it follows this package's naming conventions and provides a DelegatingStream.typed() static method.

  • Fix all strong mode warnings and add generic method annotations.

  • new StreamQueue(), new SubscriptionStream(), new DelegatingStreamSubscription(), new DelegatingStreamConsumer(), new DelegatingSink(), new DelegatingEventSink(), and new DelegatingStreamSink() now take arguments with generic type arguments (for example Stream<T>) rather than without (for example Stream<dynamic>). Passing a type that wasn't is-compatible with the fully-specified generic would already throw an error under some circumstances, so this is not considered a breaking change.

  • ErrorResult now takes a type parameter.

  • Result.asError now returns a Result<T>.

1.9.0

  • Deprecate top-level libraries other than package:async/async.dart, which exports these libraries' interfaces.

  • Add Result.captureStreamTransformer, Result.releaseStreamTransformer, Result.captureSinkTransformer, and Result.releaseSinkTransformer.

  • Deprecate CaptureStreamTransformer, ReleaseStreamTransformer, CaptureSink, and ReleaseSink. Result.captureStreamTransformer, Result.releaseStreamTransformer, Result.captureSinkTransformer, and Result.releaseSinkTransformer should be used instead.

1.8.0

  • Added StreamSinkCompleter, for creating a StreamSink now and providing its destination later as another sink.

  • Added StreamCompleter.setError, a shortcut for emitting a single error event on the resulting stream.

  • Added NullStreamSink, an implementation of StreamSink that discards all events.

1.7.0

  • Added SingleSubscriptionTransformer, a StreamTransformer that converts a broadcast stream into a single-subscription stream.

1.6.0

  • Added CancelableOperation.valueOrCancellation(), which allows users to be notified when an operation is canceled elsewhere.

  • Added StreamSinkTransformer which transforms events before they're passed to a StreamSink, similarly to how StreamTransformer transforms events after they're emitted by a stream.

1.5.0

  • Added LazyStream, which forwards to the return value of a callback that's only called when the stream is listened to.

1.4.0

  • Added AsyncMemoizer.future, which allows the result to be accessed before runOnce() is called.

  • Added CancelableOperation, an asynchronous operation that can be canceled. It can be created using a CancelableCompleter.

  • Added RestartableTimer, a non-periodic timer that can be reset over and over.

1.3.0

  • Added StreamCompleter class for creating a stream now and providing its events later as another stream.

  • Added StreamQueue class which allows requesting events from a stream before they are avilable. It is like a StreamIterator that can queue requests.

  • Added SubscriptionStream which creates a single-subscription stream from an existing stream subscription.

  • Added a ResultFuture class for synchronously accessing the result of a wrapped future.

  • Added FutureGroup.onIdle and FutureGroup.isIdle, which provide visibility into whether a group is actively waiting on any futures.

  • Add an AsyncMemoizer class for running an asynchronous block of code exactly once.

  • Added delegating wrapper classes for a number of core async types: DelegatingFuture, DelegatingStreamConsumer, DelegatingStreamController, DelegatingSink, DelegatingEventSink, DelegatingStreamSink, and DelegatingStreamSubscription. These are all simple wrappers that forward all calls to the wrapped objects. They can be used to expose only the desired interface for subclasses, or extended to add extra functionality.

1.2.0

  • Added a FutureGroup class for waiting for a group of futures, potentially of unknown size, to complete.

  • Added a StreamGroup class for merging the events of a group of streams, potentially of unknown size.

  • Added a StreamSplitter class for splitting a stream into multiple new streams.

1.1.1

  • Updated SDK version constraint to at least 1.9.0.

1.1.0

  • ChangeLog starts here.

Use this package as a library

1. Depend on it

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


dependencies:
  async: "^1.11.3"

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 flutter 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/async.dart';
  
Version Uploaded Documentation Archive
2.0.7 May 3, 2018 Go to the documentation of async 2.0.7 Download async 2.0.7 archive
2.0.6 Mar 3, 2018 Go to the documentation of async 2.0.6 Download async 2.0.6 archive
2.0.5 Feb 27, 2018 Go to the documentation of async 2.0.5 Download async 2.0.5 archive
2.0.4 Feb 10, 2018 Go to the documentation of async 2.0.4 Download async 2.0.4 archive
2.0.3 Jan 5, 2018 Go to the documentation of async 2.0.3 Download async 2.0.3 archive
2.0.2 Jan 3, 2018 Go to the documentation of async 2.0.2 Download async 2.0.2 archive
2.0.1 Oct 3, 2017 Go to the documentation of async 2.0.1 Download async 2.0.1 archive
2.0.0 Aug 29, 2017 Go to the documentation of async 2.0.0 Download async 2.0.0 archive
1.13.3 May 17, 2017 Go to the documentation of async 1.13.3 Download async 1.13.3 archive
1.13.2 Feb 20, 2017 Go to the documentation of async 1.13.2 Download async 1.13.2 archive

All 42 versions...

Analysis

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

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3

Scores

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

Platforms

Detected platforms: Flutter, web, other

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

Suggestions

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 12 errors 132 hints.

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

    line: 11 col: 7
    Missing concrete implementation of getter 'Timer.tick'.

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

    line: 93 col: 7
    The return type 'Future<Future<T>>' isn't a 'Future<T>', as defined by the method 'release'.

    Similar analysis of the following files failed:

    • lib/src/result/capture_transformer.dart (error)
    • lib/src/result/release_transformer.dart (error)
    • lib/src/single_subscription_transformer.dart (error)
    • lib/src/typed/stream.dart (error)
    • lib/src/typed_stream_transformer.dart (error)
    • lib/src/cancelable_operation.dart (hint)
    • lib/src/delegate/event_sink.dart (hint)
    • lib/src/delegate/future.dart (hint)
    • lib/src/delegate/sink.dart (hint)
    • lib/src/delegate/stream.dart (hint)
    • lib/src/delegate/stream_consumer.dart (hint)
    • lib/src/delegate/stream_sink.dart (hint)
    • lib/src/delegate/stream_subscription.dart (hint)
    • lib/src/future_group.dart (hint)
    • lib/src/lazy_stream.dart (hint)
    • lib/src/result/future.dart (hint)
    • lib/src/stream_completer.dart (hint)
    • lib/src/stream_group.dart (hint)
    • lib/src/stream_queue.dart (hint)
    • lib/src/stream_sink_completer.dart (hint)
    • lib/src/stream_sink_transformer.dart (hint)
    • lib/src/stream_sink_transformer/handler_transformer.dart (hint)
    • lib/src/stream_sink_transformer/stream_transformer_wrapper.dart (hint)
    • lib/src/stream_splitter.dart (hint)
    • lib/src/stream_zip.dart (hint)
    • lib/src/subscription_stream.dart (hint)
    • lib/src/typed/future.dart (hint)
    • lib/src/typed/stream_subscription.dart (hint)
    • lib/src/utils.dart (hint)
  • Package is getting outdated.

    The package was released 89 weeks ago.

  • 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.dart.

  • Use analysis_options.yaml.

    Rename old .analysis_options file to analysis_options.yaml.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.19.0 <2.0.0
collection ^1.5.0 1.14.10
Dev dependencies
fake_async ^0.1.2
stack_trace ^1.0.0
test ^0.12.0