diff --git a/lib/src/transformers/flat_map.dart b/lib/src/transformers/flat_map.dart index 08d911201..6bc1c3ddb 100644 --- a/lib/src/transformers/flat_map.dart +++ b/lib/src/transformers/flat_map.dart @@ -113,8 +113,7 @@ extension FlatMapExtension on Stream { /// ### Example /// /// RangeStream(4, 1) - /// .flatMap((i) => - /// TimerStream(i, Duration(minutes: i)) + /// .flatMap((i) => TimerStream(i, Duration(minutes: i)) /// .listen(print); // prints 1, 2, 3, 4 Stream flatMap(Stream mapper(T value)) => transform(FlatMapStreamTransformer(mapper)); @@ -129,8 +128,7 @@ extension FlatMapExtension on Stream { /// ### Example /// /// RangeStream(1, 4) - /// .flatMapIterable((i) => - /// Stream.fromIterable([[]i]) + /// .flatMapIterable((i) => Stream.fromIterable([[i]]) /// .listen(print); // prints 1, 2, 3, 4 Stream flatMapIterable(Stream> mapper(T value)) => transform(FlatMapStreamTransformer>(mapper)) diff --git a/lib/src/transformers/ignore_elements.dart b/lib/src/transformers/ignore_elements.dart index 6bbbd1771..356d7c65d 100644 --- a/lib/src/transformers/ignore_elements.dart +++ b/lib/src/transformers/ignore_elements.dart @@ -10,6 +10,7 @@ import 'dart:async'; /// ErrorStream(Exception()) /// ]) /// .listen(print, onError: print); // prints Exception +@Deprecated('Use the drain method from the Stream class instead') class IgnoreElementsStreamTransformer extends StreamTransformerBase { final StreamTransformer _transformer; @@ -55,5 +56,6 @@ extension IgnoreElementsExtension on Stream { /// Stream.error(Exception()) /// ]) /// .listen(print, onError: print); // prints Exception + @Deprecated('Use the drain method from the Stream class instead') Stream ignoreElements() => transform(IgnoreElementsStreamTransformer()); } diff --git a/lib/src/transformers/time_interval.dart b/lib/src/transformers/time_interval.dart index 87e5a339f..3e19e3204 100644 --- a/lib/src/transformers/time_interval.dart +++ b/lib/src/transformers/time_interval.dart @@ -98,9 +98,8 @@ class TimeInterval { } } -/// Extends the Stream class with the ability to wrap each item emitted by the -/// source Stream in a [Timestamped] object that includes the emitted item -/// and the time when the item was emitted. +/// Extends the Stream class with the ability to record the time interval +/// between consecutive values in an stream extension TimeIntervalExtension on Stream { /// Records the time interval between consecutive values in a Stream sequence. /// diff --git a/lib/src/transformers/timestamp.dart b/lib/src/transformers/timestamp.dart index e6f21bcc3..7d82e00d3 100644 --- a/lib/src/transformers/timestamp.dart +++ b/lib/src/transformers/timestamp.dart @@ -79,7 +79,9 @@ class Timestamped { } } -/// Extends the Stream class with the ability to +/// Extends the Stream class with the ability to wrap each item emitted by the +/// source Stream in a [Timestamped] object that includes the emitted item and +/// the time when the item was emitted. extension TimeStampExtension on Stream { /// Wraps each item emitted by the source Stream in a [Timestamped] object /// that includes the emitted item and the time when the item was emitted. diff --git a/test/streams/sequence_equals_test.dart b/test/streams/sequence_equals_test.dart index cdb1a7a85..026767389 100644 --- a/test/streams/sequence_equals_test.dart +++ b/test/streams/sequence_equals_test.dart @@ -96,14 +96,14 @@ void main() { }); test('Rx.sequenceEqual.asBroadcastStream', () async { - final stream = Rx.sequenceEqual(Stream.fromIterable(const [1, 2, 3, 4, 5]), + final future = Rx.sequenceEqual(Stream.fromIterable(const [1, 2, 3, 4, 5]), Stream.fromIterable(const [1, 2, 3, 4, 5])) .asBroadcastStream() - .ignoreElements(); + .drain(); // listen twice on same stream - await expectLater(stream, emitsDone); - await expectLater(stream, emitsDone); + await expectLater(future, completes); + await expectLater(future, completes); }); test('Rx.sequenceEqual.error.shouldThrowA', () { diff --git a/test/transformers/backpressure/debounce_test.dart b/test/transformers/backpressure/debounce_test.dart index 3b8e7b52f..7a78b5014 100644 --- a/test/transformers/backpressure/debounce_test.dart +++ b/test/transformers/backpressure/debounce_test.dart @@ -50,14 +50,14 @@ void main() { }); test('Rx.debounce.asBroadcastStream', () async { - final stream = _getStream() + final future = _getStream() .asBroadcastStream() .debounce((_) => Stream.fromFuture( Future.delayed(const Duration(milliseconds: 200)))) - .ignoreElements(); + .drain(); - await expectLater(stream, emitsDone); - await expectLater(stream, emitsDone); + await expectLater(future, completes); + await expectLater(future, completes); }); test('Rx.debounce.error.shouldThrowA', () async { diff --git a/test/transformers/backpressure/debounce_time_test.dart b/test/transformers/backpressure/debounce_time_test.dart index 9cfa659b5..1b81526ae 100644 --- a/test/transformers/backpressure/debounce_time_test.dart +++ b/test/transformers/backpressure/debounce_time_test.dart @@ -36,13 +36,13 @@ void main() { }); test('Rx.debounceTime.asBroadcastStream', () async { - final stream = _getStream() + final future = _getStream() .asBroadcastStream() .debounceTime(const Duration(milliseconds: 200)) - .ignoreElements(); + .drain(); - await expectLater(stream, emitsDone); - await expectLater(stream, emitsDone); + await expectLater(future, completes); + await expectLater(future, completes); }); test('Rx.debounceTime.error.shouldThrowA', () async { diff --git a/test/transformers/backpressure/sample_time_test.dart b/test/transformers/backpressure/sample_time_test.dart index c9ed45230..0428783fb 100644 --- a/test/transformers/backpressure/sample_time_test.dart +++ b/test/transformers/backpressure/sample_time_test.dart @@ -20,10 +20,12 @@ void main() { .asBroadcastStream()); await expectLater( - _getStream().transform(transformer).ignoreElements(), emitsDone); + _getStream().transform(transformer).drain(), + completes, + ); await expectLater( - _getStream().transform(transformer).ignoreElements(), - emitsDone, + _getStream().transform(transformer).drain(), + completes, ); }); diff --git a/test/transformers/backpressure/throttle_test.dart b/test/transformers/backpressure/throttle_test.dart index 4067aef90..fdaa8cd70 100644 --- a/test/transformers/backpressure/throttle_test.dart +++ b/test/transformers/backpressure/throttle_test.dart @@ -60,15 +60,15 @@ void main() { }); test('Rx.throttle.asBroadcastStream', () async { - final stream = _stream() + final future = _stream() .asBroadcastStream() .throttle( (_) => Stream.periodic(const Duration(milliseconds: 250))) - .ignoreElements(); + .drain(); // listen twice on same stream - await expectLater(stream, emitsDone); - await expectLater(stream, emitsDone); + await expectLater(future, completes); + await expectLater(future, completes); }); test('Rx.throttle.error.shouldThrowA', () async { diff --git a/test/transformers/backpressure/throttle_time_test.dart b/test/transformers/backpressure/throttle_time_test.dart index d673749c4..6c4b44425 100644 --- a/test/transformers/backpressure/throttle_time_test.dart +++ b/test/transformers/backpressure/throttle_time_test.dart @@ -33,14 +33,14 @@ void main() { }); test('Rx.throttleTime.asBroadcastStream', () async { - final stream = _stream() + final future = _stream() .asBroadcastStream() .throttleTime(const Duration(milliseconds: 250)) - .ignoreElements(); + .drain(); // listen twice on same stream - await expectLater(stream, emitsDone); - await expectLater(stream, emitsDone); + await expectLater(future, completes); + await expectLater(future, completes); }); test('Rx.throttleTime.error.shouldThrowA', () async { diff --git a/test/transformers/backpressure/window_count_test.dart b/test/transformers/backpressure/window_count_test.dart index cabad4305..675ed0499 100644 --- a/test/transformers/backpressure/window_count_test.dart +++ b/test/transformers/backpressure/window_count_test.dart @@ -84,14 +84,14 @@ void main() { }); test('Rx.windowCount.asBroadcastStream', () async { - final stream = Stream.fromIterable(const [1, 2, 3, 4]) + final future = Stream.fromIterable(const [1, 2, 3, 4]) .asBroadcastStream() .windowCount(2) - .ignoreElements(); + .drain(); // listen twice on same stream - await expectLater(stream, emitsDone); - await expectLater(stream, emitsDone); + await expectLater(future, completes); + await expectLater(future, completes); }); test('Rx.windowCount.error.shouldThrowA', () async { diff --git a/test/transformers/backpressure/window_test.dart b/test/transformers/backpressure/window_test.dart index e578b4ced..936a77325 100644 --- a/test/transformers/backpressure/window_test.dart +++ b/test/transformers/backpressure/window_test.dart @@ -90,16 +90,16 @@ void main() { }); test('Rx.window.asBroadcastStream', () async { - final stream = getStream(4) + final future = getStream(4) .asBroadcastStream() .window(Stream.periodic(const Duration(milliseconds: 160)) .take(10) .asBroadcastStream()) - .ignoreElements(); + .drain(); // listen twice on same stream - await expectLater(stream, emitsDone); - await expectLater(stream, emitsDone); + await expectLater(future, completes); + await expectLater(future, completes); }); test('Rx.window.error.shouldThrowA', () async { diff --git a/test/transformers/backpressure/window_test_test.dart b/test/transformers/backpressure/window_test_test.dart index 921ed826c..9b534ca63 100644 --- a/test/transformers/backpressure/window_test_test.dart +++ b/test/transformers/backpressure/window_test_test.dart @@ -41,14 +41,14 @@ void main() { }); test('Rx.windowTest.asBroadcastStream', () async { - final stream = Stream.fromIterable(const [1, 2, 3, 4]) + final future = Stream.fromIterable(const [1, 2, 3, 4]) .asBroadcastStream() .windowTest((i) => i % 2 == 0) - .ignoreElements(); + .drain(); // listen twice on same stream - await expectLater(stream, emitsDone); - await expectLater(stream, emitsDone); + await expectLater(future, completes); + await expectLater(future, completes); }); test('Rx.windowTest.error.shouldThrowA', () async { diff --git a/test/transformers/backpressure/window_time_test.dart b/test/transformers/backpressure/window_time_test.dart index ff9c8f0ad..7a5e396ab 100644 --- a/test/transformers/backpressure/window_time_test.dart +++ b/test/transformers/backpressure/window_time_test.dart @@ -68,14 +68,14 @@ void main() { }); test('Rx.windowTime.asBroadcastStream', () async { - final stream = getStream(4) + final future = getStream(4) .asBroadcastStream() .windowTime(const Duration(milliseconds: 160)) - .ignoreElements(); + .drain(); // listen twice on same stream - await expectLater(stream, emitsDone); - await expectLater(stream, emitsDone); + await expectLater(future, completes); + await expectLater(future, completes); }); test('Rx.windowTime.error.shouldThrowA', () async { diff --git a/test/transformers/ignore_elements_test.dart b/test/transformers/ignore_elements_test.dart index 4e0b82b92..404f6679d 100644 --- a/test/transformers/ignore_elements_test.dart +++ b/test/transformers/ignore_elements_test.dart @@ -21,6 +21,7 @@ void main() { test('Rx.ignoreElements', () async { var hasReceivedEvent = false; + // ignore: deprecated_member_use_from_same_package _getStream().ignoreElements().listen((_) { hasReceivedEvent = true; }, @@ -30,6 +31,7 @@ void main() { }); test('Rx.ignoreElements.reusable', () async { + // ignore: deprecated_member_use_from_same_package final transformer = IgnoreElementsStreamTransformer(); var hasReceivedEvent = false; @@ -49,6 +51,7 @@ void main() { }); test('Rx.ignoreElements.asBroadcastStream', () async { + // ignore: deprecated_member_use_from_same_package final stream = _getStream().asBroadcastStream().ignoreElements(); // listen twice on same stream @@ -61,6 +64,7 @@ void main() { test('Rx.ignoreElements.pause.resume', () async { var hasReceivedEvent = false; + // ignore: deprecated_member_use_from_same_package _getStream().ignoreElements().listen((_) { hasReceivedEvent = true; }, @@ -72,6 +76,7 @@ void main() { }); test('Rx.ignoreElements.error.shouldThrow', () async { + // ignore: deprecated_member_use_from_same_package final streamWithError = Stream.error(Exception()).ignoreElements(); streamWithError.listen(null,