Skip to content

Commit

Permalink
prepare for v0.2.3 (#65)
Browse files Browse the repository at this point in the history
* prepare for v0.2.3

* test: fix single_or_error_test

* refactor: `Stream.toSingleSubscriptionStream()` now returns a new `Stream` every call

* Update CHANGELOG.md
  • Loading branch information
hoc081098 authored Jul 24, 2022
1 parent 3fbbc90 commit c35308f
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 19 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 0.2.3 - Jul 22, 2022

- Fix: remove `@internal` on `StateStream.asBroadcastStateStream` extension method.
- `Stream.toSingleSubscriptionStream()` now returns a new `Stream` every call
instead of the input stream even if it's a single-subscription Stream.

## 0.2.2 - Jun 1, 2022

- Revert `path` to `^1.8.0` (because `flutter_test` from Flutter sdk (`>= 2.5.0`) depends on path `1.8.0` or `1.8.1`).
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ Liked some of my work? Buy me a coffee (or more likely a beer)

## RxDart compatibility

| **rxdart** | **rxdart_ext** |
|:-----------------------:|:---------------------:|
| `0.26.0` | `below 0.0.1` |
| `from 0.27.0 to 0.27.1` | `from 0.1.0 to 0.1.1` |
| `0.27.2` | `0.1.2` |
| `0.27.3` | `from 0.1.3 to 0.2.0` |
| `from 0.27.4 to 0.27.5` | `from 0.2.1 to 0.2.2` |
| **rxdart** | **rxdart_ext** |
|:------------------------:|:---------------------:|
| `0.26.0` | `below 0.0.1` |
| `from 0.27.0 to 0.27.1` | `from 0.1.0 to 0.1.1` |
| `0.27.2` | `0.1.2` |
| `0.27.3` | `from 0.1.3 to 0.2.0` |
| `from 0.27.4 to 0.27.5` | `from 0.2.1 to 0.2.3` |

## API

Expand Down
5 changes: 0 additions & 5 deletions lib/src/operators/to_single_subscription.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ import 'dart:async';
/// Converts a broadcast Stream into a single-subscription Stream.
extension ToSingleSubscriptionStreamExtension<T> on Stream<T> {
/// Converts a broadcast Stream into a single-subscription Stream.
/// If this [Stream] is single-subscription Stream, just return it.
Stream<T> toSingleSubscriptionStream() {
if (!isBroadcast) {
return this;
}

StreamSubscription<T>? subscription;

final controller = StreamController<T>(sync: true);
Expand Down
3 changes: 0 additions & 3 deletions lib/src/state_stream/as_broadcast.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import 'dart:async';

import 'package:meta/meta.dart';

import 'state_stream.dart';
import 'state_stream_mixin.dart';

Expand All @@ -15,7 +13,6 @@ extension BroadcastStateStreamExtensions<T> on StateStream<T> {
/// This is useful for converting a single-subscription stream into a
/// broadcast Stream. It's also useful for providing sync access to the latest
/// emitted value.
@internal
StateStream<T> asBroadcastStateStream() => _AsBroadcastStateStream(this);
}

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: rxdart_ext
description: Some extension methods and classes built on top of RxDart - RxDart extension.
version: 0.2.2
version: 0.2.3
homepage: https://github.com/hoc081098/rxdart_ext.git
repository: https://github.com/hoc081098/rxdart_ext.git
issue_tracker: https://github.com/hoc081098/rxdart_ext/issues
Expand Down
2 changes: 1 addition & 1 deletion test/operators/to_single_subscription_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void main() {
final stream = Stream.value(1);
final singleSubscriptionStream = stream.toSingleSubscriptionStream();

expect(singleSubscriptionStream, stream);
expect(singleSubscriptionStream, isNot(equals(stream)));
expect(singleSubscriptionStream.isBroadcast, isFalse);

singleSubscriptionStream.listen(null);
Expand Down
10 changes: 8 additions & 2 deletions test/single/single_or_error_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,17 @@ void main() {

test('from multiple data events Stream (data -> data)', () async {
await singleRule(
Stream.fromIterable([1, 2, 3]).singleOrError(),
Stream.fromIterable([1, 2, 3])
.toSingleSubscriptionStream() // dart 2.18.0: The Stream.fromIterable stream can now be listened to more than once.
.singleOrError(),
buildAPIContractViolationErrorWithMessage(
'Stream contains more than one data event.'),
);
broadcastRule(Stream.fromIterable([1, 2, 3]).singleOrError(), false);
broadcastRule(
Stream.fromIterable([1, 2, 3])
.toSingleSubscriptionStream() // dart 2.18.0: The Stream.fromIterable stream can now be listened to more than once.
.singleOrError(),
false);
});

test('from both data and error events Stream (data -> error)', () async {
Expand Down

0 comments on commit c35308f

Please sign in to comment.