| 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..b86e91f9192bf9bdc3a3a38f79bbba581b4e83fd 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,22 @@ 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 which throws if [subscription]'s events aren't instances
|
| + /// of `T`.
|
| + ///
|
| + /// This soundly converts a [StreamSubscription] to a `StreamSubscription<T>`,
|
| + /// regardless of its original generic type, by asserting that its events are
|
| + /// instances of `T` whenever they're provided. If they're not, the
|
| + /// subscription 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);
|
| }
|
|
|