Skip to content

Commit

Permalink
[rx_utils] typed stream
Browse files Browse the repository at this point in the history
  • Loading branch information
alextekartik committed May 13, 2024
1 parent 02d784d commit 5310d6f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app_rx_utils/lib/src/value_stream_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ValueStreamBuilder<T> extends StatelessWidget {

@override
Widget build(BuildContext context) {
return StreamBuilder(
return StreamBuilder<T>(
builder: builder,
stream: stream,
initialData: stream.hasValue ? stream.value : null,
Expand Down
2 changes: 1 addition & 1 deletion app_rx_utils/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: tekartik_app_rx_utils
description: Rx subject builder
version: 0.5.0
version: 0.5.1
publish_to: none

environment:
Expand Down
22 changes: 22 additions & 0 deletions app_rx_utils/test/app_rx_utils_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ void main() {
await subject.close();
});

test('typed subject builder', () async {
var subject = BehaviorSubject<bool>();
BehaviorSubjectBuilder(
subject: subject,
builder: (_, snapshot) =>
Switch(value: snapshot.data ?? false, onChanged: (_) {}),
);

await subject.close();
});

test('value_stream builder', () async {
var subject = BehaviorSubject<bool>();
ValueStream<bool> valueStream = subject;
Expand All @@ -24,4 +35,15 @@ void main() {

await subject.close();
});

test('typed value_stream builder', () async {
var subject = BehaviorSubject<bool>();
ValueStreamBuilder(
stream: subject,
builder: (_, snapshot) =>
Switch(value: snapshot.data ?? false, onChanged: (_) {}),
);

await subject.close();
});
}

0 comments on commit 5310d6f

Please sign in to comment.