Skip to content

Commit d0f381e

Browse files
committed
updated
1 parent 965d2e7 commit d0f381e

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ class MyBloc implements BaseBloc {
5151
```dart
5252
import 'dart:async';
5353
54-
import 'package:distinct_value_connectable_stream/distinct_value_connectable_stream.dart';
5554
import 'package:flutter_bloc_pattern/flutter_bloc_pattern.dart';
5655
import 'package:rxdart_ext/rxdart_ext.dart';
5756
@@ -60,7 +59,7 @@ class CounterBloc extends DisposeCallbackBaseBloc {
6059
final VoidAction increment;
6160
6261
/// Outputs
63-
final DistinctValueStream<int> state;
62+
final StateStream<int> state;
6463
6564
CounterBloc._({
6665
required void Function() dispose,
@@ -74,7 +73,7 @@ class CounterBloc extends DisposeCallbackBaseBloc {
7473
7574
final state = incrementController.stream
7675
.scan<int>((acc, _, __) => acc + 1, 0)
77-
.publishValueDistinct(0);
76+
.publishState(0);
7877
final connection = state.connect();
7978
8079
return CounterBloc._(
@@ -88,7 +87,6 @@ class CounterBloc extends DisposeCallbackBaseBloc {
8887
);
8988
}
9089
}
91-
9290
```
9391

9492
### 2. File `main.dart`:

lib/src/rx_stream_builder.dart

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'dart:async';
22

3+
import 'package:flutter/foundation.dart';
34
import 'package:flutter/widgets.dart';
45
import 'package:rxdart/rxdart.dart';
56
import 'package:rxdart_ext/rxdart_ext.dart';
@@ -46,7 +47,7 @@ class RxStreamBuilder<T> extends StatefulWidget {
4647
@override
4748
_RxStreamBuilderState<T> createState() => _RxStreamBuilderState();
4849

49-
/// Get latest value from stream or return `null`.
50+
/// Get latest value from stream or throw an [ArgumentError].
5051
@visibleForTesting
5152
static T getInitialData<T>(ValueStream<T> stream) {
5253
if (stream is StateStream<T>) {
@@ -55,7 +56,7 @@ class RxStreamBuilder<T> extends StatefulWidget {
5556
if (stream.hasValue) {
5657
return stream.value;
5758
}
58-
throw ArgumentError.value(stream, 'stream', 'does not have value');
59+
throw ArgumentError.value(stream, 'stream', 'has no value');
5960
}
6061
}
6162

@@ -123,4 +124,12 @@ class _RxStreamBuilderState<T> extends State<RxStreamBuilder<T>> {
123124
subscription?.cancel();
124125
subscription = null;
125126
}
127+
128+
@override
129+
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
130+
super.debugFillProperties(properties);
131+
properties.add(DiagnosticsProperty.lazy('value', () => value));
132+
properties.add(DiagnosticsProperty('subscription', subscription));
133+
properties.add(DiagnosticsProperty('stream', widget._stream));
134+
}
126135
}

0 commit comments

Comments
 (0)