Drop `fromBind` utility (dart-lang/stream_transform#59)
Replace with `StreamTransformer.fromBind` which is now in the SDK.
diff --git a/pkgs/stream_transform/lib/src/bind.dart b/pkgs/stream_transform/lib/src/bind.dart
deleted file mode 100644
index eefdc60..0000000
--- a/pkgs/stream_transform/lib/src/bind.dart
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-import 'dart:async';
-
-/// Matches [StreamTransformer.bind].
-typedef Stream<T> Bind<S, T>(Stream<S> values);
-
-/// Creates a [StreamTransformer] which overrides [StreamTransformer.bind] to
-/// [bindFn].
-StreamTransformer<S, T> fromBind<S, T>(Bind<S, T> bindFn) =>
- _StreamTransformer(bindFn);
-
-class _StreamTransformer<S, T> extends StreamTransformerBase<S, T> {
- final Bind<S, T> _bind;
-
- _StreamTransformer(this._bind);
-
- @override
- Stream<T> bind(Stream<S> values) => _bind(values);
-}
diff --git a/pkgs/stream_transform/lib/src/chain_transformers.dart b/pkgs/stream_transform/lib/src/chain_transformers.dart
index 50d8be4..549befc 100644
--- a/pkgs/stream_transform/lib/src/chain_transformers.dart
+++ b/pkgs/stream_transform/lib/src/chain_transformers.dart
@@ -4,8 +4,6 @@
import 'dart:async';
-import 'bind.dart';
-
/// Combines two transformers into one.
///
/// This is most useful to keep a reference to the combination and use it in
@@ -21,4 +19,5 @@
/// ```
StreamTransformer<S, T> chainTransformers<S, I, T>(
StreamTransformer<S, I> first, StreamTransformer<I, T> second) =>
- fromBind((values) => values.transform(first).transform(second));
+ StreamTransformer.fromBind(
+ (values) => values.transform(first).transform(second));
diff --git a/pkgs/stream_transform/lib/src/map.dart b/pkgs/stream_transform/lib/src/map.dart
index 8bce550..09ea0d6 100644
--- a/pkgs/stream_transform/lib/src/map.dart
+++ b/pkgs/stream_transform/lib/src/map.dart
@@ -4,8 +4,6 @@
import 'dart:async';
-import 'bind.dart';
-
/// Models a [Stream.map] callback as a [StreamTransformer].
///
/// This is most useful to pass to functions that take a [StreamTransformer]
@@ -19,4 +17,4 @@
/// map((v) => '$v'));
/// ```
StreamTransformer<S, T> map<S, T>(T convert(S event)) =>
- fromBind((stream) => stream.map(convert));
+ StreamTransformer.fromBind((stream) => stream.map(convert));
diff --git a/pkgs/stream_transform/lib/src/scan.dart b/pkgs/stream_transform/lib/src/scan.dart
index fb8c745..0936e13 100644
--- a/pkgs/stream_transform/lib/src/scan.dart
+++ b/pkgs/stream_transform/lib/src/scan.dart
@@ -1,15 +1,14 @@
// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import 'dart:async';
-import 'bind.dart';
+import 'dart:async';
/// Scan is like fold, but instead of producing a single value it yields
/// each intermediate accumulation.
StreamTransformer<S, T> scan<S, T>(
T initialValue, T combine(T previousValue, S element)) =>
- fromBind((stream) {
+ StreamTransformer.fromBind((stream) {
var accumulated = initialValue;
return stream.map((value) => accumulated = combine(accumulated, value));
});
diff --git a/pkgs/stream_transform/lib/src/start_with.dart b/pkgs/stream_transform/lib/src/start_with.dart
index 1ddde0c..fbaf46a 100644
--- a/pkgs/stream_transform/lib/src/start_with.dart
+++ b/pkgs/stream_transform/lib/src/start_with.dart
@@ -4,7 +4,6 @@
import 'dart:async';
-import 'bind.dart';
import 'followed_by.dart';
/// Emits [initial] before any values from the original stream.
@@ -27,7 +26,7 @@
/// the original stream is a broadcast stream it will miss any events which
/// occur before [initial] closes.
StreamTransformer<T, T> startWithStream<T>(Stream<T> initial) =>
- fromBind((values) {
+ StreamTransformer.fromBind((values) {
if (values.isBroadcast && !initial.isBroadcast) {
initial = initial.asBroadcastStream();
}
diff --git a/pkgs/stream_transform/pubspec.yaml b/pkgs/stream_transform/pubspec.yaml
index 81c1043..b32a050 100644
--- a/pkgs/stream_transform/pubspec.yaml
+++ b/pkgs/stream_transform/pubspec.yaml
@@ -5,7 +5,7 @@
version: 0.0.15-dev
environment:
- sdk: ">=2.0.0 <3.0.0"
+ sdk: ">=2.1.0 <3.0.0"
dev_dependencies:
test: ^1.0.0