| Index: lib/src/delegate/stream_subscription.dart
|
| diff --git a/lib/src/delegate/stream_subscription.dart b/lib/src/delegate/stream_subscription.dart
|
| index e7153b2a6db6a640547abec2e5879f592cfbfba0..4913c8b0a24280d95dd3864f399735b2c01d95b1 100644
|
| --- a/lib/src/delegate/stream_subscription.dart
|
| +++ b/lib/src/delegate/stream_subscription.dart
|
| @@ -4,6 +4,8 @@
|
|
|
| import 'dart:async';
|
|
|
| +import '../typed/stream_subscription.dart';
|
| +
|
| /// Simple delegating wrapper around a [StreamSubscription].
|
| ///
|
| /// Subclasses can override individual methods.
|
| @@ -11,9 +13,21 @@ class DelegatingStreamSubscription<T> implements StreamSubscription<T> {
|
| final StreamSubscription _source;
|
|
|
| /// Create delegating subscription forwarding calls to [sourceSubscription].
|
| - DelegatingStreamSubscription(StreamSubscription sourceSubscription)
|
| + DelegatingStreamSubscription(StreamSubscription<T> sourceSubscription)
|
| : _source = sourceSubscription;
|
|
|
| + /// Creates a wrapper that asserts the types of the values emitted by
|
| + /// [subscription].
|
| + ///
|
| + /// This soundly converts a [StreamSubscription] without a generic type to a
|
| + /// `StreamSubscription<T>` by asserting that its events are instances of `T`
|
| + /// whenever they're accessed. If they're not, it throws a [CastError].
|
| + static StreamSubscription/*<T>*/ typed/*<T>*/(
|
| + StreamSubscription subscription) =>
|
| + subscription is StreamSubscription/*<T>*/
|
| + ? subscription
|
| + : new TypeSafeStreamSubscription/*<T>*/(subscription);
|
| +
|
| void onData(void handleData(T data)) {
|
| _source.onData(handleData);
|
| }
|
|
|