Drop the _WhereType transformer definition (dart-lang/stream_transform#98)
This was only required because of the challenges of being exposed as a
`StreamTransformer` and the subtyping rules for the generic arguments.
Now that we aren't exposing it as `StreamTransformer` we don't need
extra complications.
diff --git a/pkgs/stream_transform/lib/src/where.dart b/pkgs/stream_transform/lib/src/where.dart
index 850e9a9..8917cb4 100644
--- a/pkgs/stream_transform/lib/src/where.dart
+++ b/pkgs/stream_transform/lib/src/where.dart
@@ -17,7 +17,7 @@
/// [S] should be a subtype of the stream's generic type, otherwise nothing of
/// type [S] could possibly be emitted, however there is no static or runtime
/// checking that this is the case.
- Stream<S> whereType<S>() => transform(_WhereType<S>());
+ Stream<S> whereType<S>() => where((e) => e is S).cast<S>();
/// Like [where] but allows the [test] to return a [Future].
///
@@ -54,36 +54,3 @@
}));
}
}
-
-class _WhereType<R> extends StreamTransformerBase<Null, R> {
- @override
- Stream<R> bind(Stream<Object> source) {
- var controller = source.isBroadcast
- ? StreamController<R>.broadcast(sync: true)
- : StreamController<R>(sync: true);
-
- StreamSubscription<Object> subscription;
- controller.onListen = () {
- assert(subscription == null);
- subscription = source.listen(
- (value) {
- if (value is R) controller.add(value);
- },
- onError: controller.addError,
- onDone: () {
- subscription = null;
- controller.close();
- });
- if (!source.isBroadcast) {
- controller
- ..onPause = subscription.pause
- ..onResume = subscription.resume;
- }
- controller.onCancel = () {
- subscription?.cancel();
- subscription = null;
- };
- };
- return controller.stream;
- }
-}
diff --git a/pkgs/stream_transform/pubspec.yaml b/pkgs/stream_transform/pubspec.yaml
index 62a7fa6..9f98a71 100644
--- a/pkgs/stream_transform/pubspec.yaml
+++ b/pkgs/stream_transform/pubspec.yaml
@@ -1,7 +1,7 @@
name: stream_transform
description: A collection of utilities to transform and manipulate streams.
homepage: https://www.github.com/dart-lang/stream_transform
-version: 1.1.1
+version: 1.1.2-dev
environment:
sdk: ">=2.6.0 <3.0.0"