Skip to content

Commit a1c8235

Browse files
committed
Update PR based on feedback
- Deprecate ignoreElements - Update docs for TimerInterval and TimeStamped - Update docs for flatMap
1 parent e28e32f commit a1c8235

15 files changed

+55
-47
lines changed

lib/src/transformers/flat_map.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,7 @@ extension FlatMapExtension<T> on Stream<T> {
113113
/// ### Example
114114
///
115115
/// RangeStream(4, 1)
116-
/// .flatMap((i) =>
117-
/// TimerStream(i, Duration(minutes: i))
116+
/// .flatMap((i) => TimerStream(i, Duration(minutes: i))
118117
/// .listen(print); // prints 1, 2, 3, 4
119118
Stream<S> flatMap<S>(Stream<S> mapper(T value)) =>
120119
transform(FlatMapStreamTransformer<T, S>(mapper));
@@ -129,8 +128,7 @@ extension FlatMapExtension<T> on Stream<T> {
129128
/// ### Example
130129
///
131130
/// RangeStream(1, 4)
132-
/// .flatMapIterable((i) =>
133-
/// Stream.fromIterable([[]i])
131+
/// .flatMapIterable((i) => Stream.fromIterable([[i]])
134132
/// .listen(print); // prints 1, 2, 3, 4
135133
Stream<S> flatMapIterable<S>(Stream<Iterable<S>> mapper(T value)) =>
136134
transform(FlatMapStreamTransformer<T, Iterable<S>>(mapper))

lib/src/transformers/ignore_elements.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import 'dart:async';
1010
/// ErrorStream(Exception())
1111
/// ])
1212
/// .listen(print, onError: print); // prints Exception
13+
@Deprecated('Use the drain method from the Stream class instead')
1314
class IgnoreElementsStreamTransformer<T> extends StreamTransformerBase<T, T> {
1415
final StreamTransformer<T, T> _transformer;
1516

@@ -55,5 +56,6 @@ extension IgnoreElementsExtension<T> on Stream<T> {
5556
/// Stream.error(Exception())
5657
/// ])
5758
/// .listen(print, onError: print); // prints Exception
59+
@Deprecated('Use the drain method from the Stream class instead')
5860
Stream<T> ignoreElements() => transform(IgnoreElementsStreamTransformer<T>());
5961
}

lib/src/transformers/time_interval.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,8 @@ class TimeInterval<T> {
9898
}
9999
}
100100

101-
/// Extends the Stream class with the ability to wrap each item emitted by the
102-
/// source Stream in a [Timestamped] object that includes the emitted item
103-
/// and the time when the item was emitted.
101+
/// Extends the Stream class with the ability to record the time interval
102+
/// between consecutive values in an stream
104103
extension TimeIntervalExtension<T> on Stream<T> {
105104
/// Records the time interval between consecutive values in a Stream sequence.
106105
///

lib/src/transformers/timestamp.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ class Timestamped<T> {
7979
}
8080
}
8181

82-
/// Extends the Stream class with the ability to
82+
/// Extends the Stream class with the ability to wrap each item emitted by the
83+
/// source Stream in a [Timestamped] object that includes the emitted item and
84+
/// the time when the item was emitted.
8385
extension TimeStampExtension<T> on Stream<T> {
8486
/// Wraps each item emitted by the source Stream in a [Timestamped] object
8587
/// that includes the emitted item and the time when the item was emitted.

test/streams/sequence_equals_test.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,14 @@ void main() {
9696
});
9797

9898
test('Rx.sequenceEqual.asBroadcastStream', () async {
99-
final stream = Rx.sequenceEqual(Stream.fromIterable(const [1, 2, 3, 4, 5]),
99+
final future = Rx.sequenceEqual(Stream.fromIterable(const [1, 2, 3, 4, 5]),
100100
Stream.fromIterable(const [1, 2, 3, 4, 5]))
101101
.asBroadcastStream()
102-
.ignoreElements();
102+
.drain<void>();
103103

104104
// listen twice on same stream
105-
await expectLater(stream, emitsDone);
106-
await expectLater(stream, emitsDone);
105+
await expectLater(future, completes);
106+
await expectLater(future, completes);
107107
});
108108

109109
test('Rx.sequenceEqual.error.shouldThrowA', () {

test/transformers/backpressure/debounce_test.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ void main() {
5050
});
5151

5252
test('Rx.debounce.asBroadcastStream', () async {
53-
final stream = _getStream()
53+
final future = _getStream()
5454
.asBroadcastStream()
5555
.debounce((_) => Stream<void>.fromFuture(
5656
Future<void>.delayed(const Duration(milliseconds: 200))))
57-
.ignoreElements();
57+
.drain<void>();
5858

59-
await expectLater(stream, emitsDone);
60-
await expectLater(stream, emitsDone);
59+
await expectLater(future, completes);
60+
await expectLater(future, completes);
6161
});
6262

6363
test('Rx.debounce.error.shouldThrowA', () async {

test/transformers/backpressure/debounce_time_test.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ void main() {
3636
});
3737

3838
test('Rx.debounceTime.asBroadcastStream', () async {
39-
final stream = _getStream()
39+
final future = _getStream()
4040
.asBroadcastStream()
4141
.debounceTime(const Duration(milliseconds: 200))
42-
.ignoreElements();
42+
.drain<void>();
4343

44-
await expectLater(stream, emitsDone);
45-
await expectLater(stream, emitsDone);
44+
await expectLater(future, completes);
45+
await expectLater(future, completes);
4646
});
4747

4848
test('Rx.debounceTime.error.shouldThrowA', () async {

test/transformers/backpressure/sample_time_test.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@ void main() {
2020
.asBroadcastStream());
2121

2222
await expectLater(
23-
_getStream().transform(transformer).ignoreElements(), emitsDone);
23+
_getStream().transform(transformer).drain<void>(),
24+
completes,
25+
);
2426
await expectLater(
25-
_getStream().transform(transformer).ignoreElements(),
26-
emitsDone,
27+
_getStream().transform(transformer).drain<void>(),
28+
completes,
2729
);
2830
});
2931

test/transformers/backpressure/throttle_test.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ void main() {
6060
});
6161

6262
test('Rx.throttle.asBroadcastStream', () async {
63-
final stream = _stream()
63+
final future = _stream()
6464
.asBroadcastStream()
6565
.throttle(
6666
(_) => Stream<void>.periodic(const Duration(milliseconds: 250)))
67-
.ignoreElements();
67+
.drain<void>();
6868

6969
// listen twice on same stream
70-
await expectLater(stream, emitsDone);
71-
await expectLater(stream, emitsDone);
70+
await expectLater(future, completes);
71+
await expectLater(future, completes);
7272
});
7373

7474
test('Rx.throttle.error.shouldThrowA', () async {

test/transformers/backpressure/throttle_time_test.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ void main() {
3333
});
3434

3535
test('Rx.throttleTime.asBroadcastStream', () async {
36-
final stream = _stream()
36+
final future = _stream()
3737
.asBroadcastStream()
3838
.throttleTime(const Duration(milliseconds: 250))
39-
.ignoreElements();
39+
.drain<void>();
4040

4141
// listen twice on same stream
42-
await expectLater(stream, emitsDone);
43-
await expectLater(stream, emitsDone);
42+
await expectLater(future, completes);
43+
await expectLater(future, completes);
4444
});
4545

4646
test('Rx.throttleTime.error.shouldThrowA', () async {

0 commit comments

Comments
 (0)