Skip to content

Commit 75161ba

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

File tree

5 files changed

+14
-8
lines changed

5 files changed

+14
-8
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/transformers/ignore_elements_test.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ void main() {
2121
test('Rx.ignoreElements', () async {
2222
var hasReceivedEvent = false;
2323

24+
// ignore: deprecated_member_use_from_same_package
2425
_getStream().ignoreElements().listen((_) {
2526
hasReceivedEvent = true;
2627
},
@@ -30,6 +31,7 @@ void main() {
3031
});
3132

3233
test('Rx.ignoreElements.reusable', () async {
34+
// ignore: deprecated_member_use_from_same_package
3335
final transformer = IgnoreElementsStreamTransformer<int>();
3436
var hasReceivedEvent = false;
3537

@@ -49,6 +51,7 @@ void main() {
4951
});
5052

5153
test('Rx.ignoreElements.asBroadcastStream', () async {
54+
// ignore: deprecated_member_use_from_same_package
5255
final stream = _getStream().asBroadcastStream().ignoreElements();
5356

5457
// listen twice on same stream
@@ -61,6 +64,7 @@ void main() {
6164
test('Rx.ignoreElements.pause.resume', () async {
6265
var hasReceivedEvent = false;
6366

67+
// ignore: deprecated_member_use_from_same_package
6468
_getStream().ignoreElements().listen((_) {
6569
hasReceivedEvent = true;
6670
},
@@ -72,6 +76,7 @@ void main() {
7276
});
7377

7478
test('Rx.ignoreElements.error.shouldThrow', () async {
79+
// ignore: deprecated_member_use_from_same_package
7580
final streamWithError = Stream<void>.error(Exception()).ignoreElements();
7681

7782
streamWithError.listen(null,

0 commit comments

Comments
 (0)