-
Notifications
You must be signed in to change notification settings - Fork 277
add ValueStream.isReplayValueStream
#784
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…eplayValueStream # Conflicts: # examples/flutter/github_search/lib/search_screen.dart # examples/flutter/github_search/pubspec.lock
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request introduces the isReplayValueStream property to the ValueStream interface to indicate whether a stream replays its last emitted event to new subscribers. This enables more flexible stream handling and allows Flutter widgets to dynamically determine stream behavior instead of relying on hardcoded defaults.
- Adds
isReplayValueStreamproperty toValueStreaminterface and implementations - Updates Flutter widgets to use the new property instead of hardcoded
truedefaults - Refactors example app to use updated RxDart API
Reviewed Changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/rxdart/lib/src/streams/value_stream.dart | Adds isReplayValueStream property to ValueStream interface |
| packages/rxdart/lib/src/subjects/behavior_subject.dart | Implements isReplayValueStream in BehaviorSubject classes |
| packages/rxdart/lib/src/streams/connectable_stream.dart | Implements isReplayValueStream in ValueConnectableStream |
| packages/rxdart_flutter/lib/src/value_stream_*.dart | Updates Flutter widgets to use dynamic stream property |
| packages/rxdart_flutter/test/src/rxdart_ext/value_subject.dart | Implements property in test helper classes |
| examples/flutter/github_search/lib/bloc/search_bloc.dart | Updates example to use new RxDart API |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| _ambiguate(WidgetsBinding.instance)!.addPostFrameCallback((_) { | ||
| if (widget.stream != stream) { | ||
| return; | ||
| } | ||
| _notifyListener(stream.value); | ||
| _subscribeIfNeeded(stream); |
Copilot
AI
Sep 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This condition uses widget.stream instead of _currentStream which could cause incorrect behavior. The condition should check if the current stream has changed since the callback was scheduled.
| _ambiguate(WidgetsBinding.instance)!.addPostFrameCallback((_) { | |
| if (widget.stream != stream) { | |
| return; | |
| } | |
| _notifyListener(stream.value); | |
| _subscribeIfNeeded(stream); | |
| final scheduledStream = stream; | |
| _ambiguate(WidgetsBinding.instance)!.addPostFrameCallback((_) { | |
| if (widget.stream != scheduledStream) { | |
| return; | |
| } | |
| _notifyListener(scheduledStream.value); | |
| _subscribeIfNeeded(scheduledStream); |
| void _subscribeIfNeeded(Stream<T> streamToListen) { | ||
| if (_subscription != null) { | ||
| return; | ||
| } |
Copilot
AI
Sep 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method name _subscribeIfNeeded is misleading because it only checks if _subscription is null, but doesn't verify if the subscription is for the correct stream. This could lead to using an outdated subscription when the stream changes.
This pull request includes significant updates to the
examples/flutter/github_searchandpackages/rxdartdirectories, focusing on stream handling and improving theValueStreamfunctionality. The most important changes include updating dependencies, modifying stream classes and widgets, and adding new properties to enhance stream behavior.Updates to
examples/flutter/github_search:examples/flutter/github_search/lib/bloc/search_bloc.dart: ReplacedStateStreamwithValueStreamand updated thepublishStatemethod topublishValueSeeded. [1] [2]examples/flutter/github_search/pubspec.yaml: Removedrxdart_extdependency.Enhancements to
packages/rxdart:packages/rxdart/lib/src/streams/connectable_stream.dart: AddedisReplayValueStreamproperty toValueConnectableStream.packages/rxdart/lib/src/streams/replay_stream.dart: UpdatedReplayStreamdocumentation to reflect replay behavior.packages/rxdart/lib/src/streams/value_stream.dart: IntroducedisReplayValueStreamproperty toValueStreaminterface.packages/rxdart/lib/src/subjects/behavior_subject.dart: ImplementedisReplayValueStreaminBehaviorSubjectand_BehaviorSubjectStream. [1] [2]Improvements to
packages/rxdart_flutter:packages/rxdart_flutter/lib/src/value_stream_builder.dart: UpdatedValueStreamBuilderto useisReplayValueStreamproperty and modified its default behavior. [1] [2] [3]packages/rxdart_flutter/lib/src/value_stream_consumer.dart: Similar updates toValueStreamConsumerto handleisReplayValueStream. [1] [2] [3]packages/rxdart_flutter/lib/src/value_stream_listener.dart: EnhancedValueStreamListenerwithisReplayValueStreamproperty and refactored subscription logic. [1] [2] [3] [4] [5]Additional changes:
packages/rxdart/test/subject/behavior_subject_test.dart: Added tests forisReplayValueStreamproperty inBehaviorSubject.packages/rxdart_flutter/test/src/rxdart_ext/value_subject.dart: ImplementedisReplayValueStreaminValueSubjectand_ValueSubjectStream. [1] [2]