From bf98422dd0f9303a03adb409b15fd90d5b3a4c39 Mon Sep 17 00:00:00 2001 From: Petrus Nguyen Thai Hoc Date: Mon, 8 Feb 2021 18:12:53 +0700 Subject: [PATCH] docs --- README.md | 25 +++++++++++++------------ lib/src/ignore.dart | 20 +++++++++++++------- lib/src/where_not_null.dart | 2 +- 3 files changed, 27 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 81f49ed..56ec4fb 100644 --- a/README.md +++ b/README.md @@ -6,18 +6,19 @@ Some extension methods and classes built on top of `RxDart` - `RxDart` extension ![Dart CI](https://github.com/hoc081098/rxdart_ext/workflows/Dart%20CI/badge.svg) [![Pub Version (including pre-releases)](https://img.shields.io/pub/v/rxdart_ext?include_prereleases)](https://pub.dev/packages/rxdart_ext) -- `debug`, `collect` -- `ForwardingSinkMixin` -- `distinctUniqueBy` -- `distinctBy` -- `ignoreElements`, `ignoreErrors` -- `mapNotNull` -- `toSingleSubscription` -- `NotReplayValueStream` +- [debug](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/DebugStreamExtension/debug.html), [collect](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/CollectStreamExtension/collect.html) +- [ForwardingSinkMixin](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/ForwardingSinkMixin-mixin.html) +- [distinctUniqueBy](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/DistinctUniqueByStreamExtension/distinctUniqueBy.html) +- [distinctBy](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/DistinctByExtension/distinctBy.html) +- [ignoreElements](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/IgnoreElementStreamExtension/ignoreElements.html), [ignoreErrors](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/IgnoreErrorsStreamExtension/ignoreErrors.html) +- [mapNotNull](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/MapNotNullStreamExtension/mapNotNull.html) +- [toSingleSubscription](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/ToSingleSubscriptionStreamExtension/toSingleSubscriptionStream.html) +- [whereNotNull](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/WhereNotNullStreamExtension/whereNotNull.html) +- [NotReplayValueStream](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/NotReplayValueStream-class.html) - Broadcast - - `ValueSubject` - - `NotReplayValueConnectableStream`, `publishValueNotReplay`, `shareValueNotReplay` + - [ValueSubject](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/ValueSubject-class.html) + - [NotReplayValueConnectableStream](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/NotReplayValueConnectableStream-class.html), [publishValueNotReplay](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/ValueConnectableNotReplayStreamExtensions/publishValueNotReplay.html), [shareValueNotReplay](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/ValueConnectableNotReplayStreamExtensions/shareValueNotReplay.html) - Single-subscription - - `ValueStreamController` - - `toNotReplayValueStream` + - [ValueStreamController](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/ValueStreamController-class.html) + - [toNotReplayValueStream](https://pub.dev/documentation/rxdart_ext/latest/rxdart_ext/ToNotReplayValueStreamExtension/toNotReplayValueStream.html) diff --git a/lib/src/ignore.dart b/lib/src/ignore.dart index 69e5a4e..8bd5216 100644 --- a/lib/src/ignore.dart +++ b/lib/src/ignore.dart @@ -1,5 +1,7 @@ import 'dart:async'; +import 'default_sink.dart'; + /// Ignore all data events, forward error and done event. extension IgnoreElementStreamExtension on Stream { /// Ignore all data events, forward error and done event. @@ -12,14 +14,18 @@ extension IgnoreElementStreamExtension on Stream { } } +class _IgnoreErrorsStreamSink + with ForwardingSinkMixin + implements ForwardingSink { + @override + void add(EventSink sink, T data) {} + + @override + void addError(EventSink sink, Object error, [StackTrace? st]) {} +} + /// Ignore all error events, forward data and done event. extension IgnoreErrorsStreamExtension on Stream { /// Ignore all error events, forward data and done event. - Stream ignoreErrors() { - return transform( - StreamTransformer.fromHandlers( - handleError: (e, s, sink) {}, - ), - ); - } + Stream ignoreErrors() => forwardStream(this, _IgnoreErrorsStreamSink()); } diff --git a/lib/src/where_not_null.dart b/lib/src/where_not_null.dart index 4349fba..cd0c5f4 100644 --- a/lib/src/where_not_null.dart +++ b/lib/src/where_not_null.dart @@ -16,7 +16,7 @@ class _WhereNotNullStreamSink /// Extends the Stream class with the ability to convert the source Stream /// to a Stream which emits all the non-`null` elements /// of this Stream, in their original emission order. -extension WhereNotNullExtension on Stream { +extension WhereNotNullStreamExtension on Stream { /// Returns a Stream which emits all the non-`null` elements /// of this Stream, in their original emission order. ///