diff --git a/CHANGELOG.md b/CHANGELOG.md index e1c8861..44e1454 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 1.2.0-nullsafety.2 - Jan 9, 2021 + +- **Breaking change**: Any errors from upstream and from `equals` callback will be not added to Stream. + They are considered unhandled, and will be passed to the current `Zone`'s error handler. + By default, unhandled async errors are treated as if they were uncaught top-level errors. + ## 1.2.0-nullsafety.1 - Jan 8, 2021 - Update README.md. diff --git a/analysis_options.yaml b/analysis_options.yaml index 54f6adf..e45d257 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -4,10 +4,6 @@ analyzer: strong-mode: implicit-casts: false implicit-dynamic: false - exclude: - # Ignore generated files - - "**/*.g.dart" - - "lib/src/generated/*.dart" linter: rules: diff --git a/lib/src/distinct_value_connectable_stream.dart b/lib/src/distinct_value_connectable_stream.dart index 51138ac..a488521 100644 --- a/lib/src/distinct_value_connectable_stream.dart +++ b/lib/src/distinct_value_connectable_stream.dart @@ -99,8 +99,9 @@ class DistinctValueConnectableStream extends ConnectableStream } @override - ErrorAndStackTrace? get errorAndStackTrace => null; + Never get errorAndStackTrace => + throw StateError('This Stream always has no error!'); @override - ValueWrapper? get valueWrapper => _subject.valueWrapper; + ValueWrapper get valueWrapper => _subject.valueWrapper!; } diff --git a/lib/src/distinct_value_stream.dart b/lib/src/distinct_value_stream.dart index 54b2ede..f70bfbd 100644 --- a/lib/src/distinct_value_stream.dart +++ b/lib/src/distinct_value_stream.dart @@ -1,4 +1,5 @@ -import 'package:rxdart_ext/rxdart_ext.dart' show NotReplayValueStream; +import 'package:rxdart_ext/rxdart_ext.dart' + show NotReplayValueStream, ValueWrapper; /// An [Stream] that provides synchronous access to the last emitted item, /// and two consecutive values are not equal. @@ -10,4 +11,10 @@ abstract class DistinctValueStream extends NotReplayValueStream { /// Default [equals] function. /// Use '==' operator on the last provided data element. static bool defaultEquals(T lhs, T rhs) => lhs == rhs; + + @override + Never get errorAndStackTrace; + + @override + ValueWrapper get valueWrapper; } diff --git a/pubspec.yaml b/pubspec.yaml index dee61bf..8f0dd10 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: distinct_value_connectable_stream description: Distinct value connectable stream for RxDart, useful for BLoC pattern -version: 1.2.0-nullsafety.1 +version: 1.2.0-nullsafety.2 homepage: https://github.com/hoc081098/distinct_value_connectable_stream environment: diff --git a/test/distinct_value_connectable_stream_test.dart b/test/distinct_value_connectable_stream_test.dart index 0e1ca62..f2cfc67 100644 --- a/test/distinct_value_connectable_stream_test.dart +++ b/test/distinct_value_connectable_stream_test.dart @@ -248,6 +248,33 @@ void main() { expect(() => stream.refCount(), throwsStateError); expect(() => stream.autoConnect(), throwsStateError); }); + + test('nullable generic type', () { + expect( + Stream.fromIterable([ + null, + 1, + 2, + null, + 3, + 4, + 4, + null, + null, + ]).shareValueDistinct(null), + emitsInOrder( + [ + 1, + 2, + null, + 3, + 4, + null, + emitsDone, + ], + ), + ); + }); }); }