Skip to content
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

feat(rxdart_flutter): add ValueStream widgets #782

Merged
merged 11 commits into from
Feb 1, 2025

Conversation

GiancarloCante
Copy link
Contributor

Add three new Flutter widgets for working with ValueStreams:

  • ValueStreamBuilder: A widget that rebuilds UI based on ValueStream updates
  • ValueStreamListener: A widget that performs side effects when ValueStream values change
  • ValueStreamConsumer: A widget combining both builder and listener capabilities for ValueStreams

Features:

  • Optimized for ValueStreams with required initial values
  • Proper error handling for streams without values/with errors
  • Optional buildWhen condition for controlling rebuilds
  • Access to previous/current values in listeners
  • 100% test coverage
  • Detailed documentation and examples

Closes #779

Add three new Flutter widgets for working with ValueStreams:
- `ValueStreamBuilder`: A widget that rebuilds UI based on `ValueStream` updates
- `ValueStreamListener`: A widget that performs side effects when `ValueStream` values change
- `ValueStreamConsumer`: A widget combining both builder and listener capabilities for `ValueStream`s

Features:
- Optimized for ValueStreams with required initial values
- Proper error handling for streams without values/with errors
- Optional buildWhen condition for controlling rebuilds
- Access to previous/current values in listeners
- 100% test coverage
- Detailed documentation and examples
@hoc081098
Copy link
Collaborator

Thank you for your PR, I will take a look at it ASAP.

Enhance error handling in `validateValueStreamInitialValue` by:
- Preserving the original stream's stack trace when available
- Falling back to `StackTrace.current` only when no stack trace is present
…dencies

- Remove local import of rxdart_flutter.dart
- Add direct import of rxdart package
- Import ValueStreamListener
- Streamline import statements for better modularity
…handling

Improve the initial value handling in ValueStreamListener by:
- Dynamically adjusting skip count based on initialization state
- Removing post-frame callback for initial value notification
- Remove null assertion from currentValue in ValueStreamBuilder and ValueStreamConsumer
- Add test cases for nullable types
- Improve test variable naming for better readability
…gets

- Update ValueStreamBuilder, ValueStreamConsumer, and related tests to support an optional `child` parameter
- Modify builder signatures to include child widget
- Add documentation explaining the purpose and usage of the child parameter
- Enhance example code to demonstrate stable child widget usage
- Replace BehaviorSubject with ValueStream in tests apps
- Introduce `isReplayValueStream` parameter to ValueStream widgets
- Update ValueStreamBuilder, ValueStreamConsumer, and ValueStreamListener to handle non-replay streams
- Add comprehensive test cases for non-replay stream scenarios
- Modify listener and builder behaviors based on stream replay configuration
- Update debug properties to include `isReplayValueStream`
@hoc081098
Copy link
Collaborator

hoc081098 commented Jan 31, 2025

It looks good to me 🙏

Could you please update the flutter_search sample as well? It seems that the builder signature has been changed (with the addition of child param).

  error • The argument type 'Scaffold Function(BuildContext, SearchState)' can't be assigned to the parameter type 'ValueStreamWidgetBuilder<SearchState>'.  • lib/search_screen.dart:50:16 • argument_type_not_assignable

…ner issues

Updated package dependencies via flutter pub upgrade to fix
build_runner execution failures.
- Add network client entitlements for debug and release configurations
- Update AppDelegate with @main annotation and secure restorable state method
- Upgrade Xcode project to version 1510
- Add RunnerTests target with a basic test case
- Simplify FlutterViewController initialization
Improve stream skipping logic in ValueStreamListener by:
- Conditionally applying skip only when skipCount is greater than 0
- Simplify stream listening mechanism
@GiancarloCante
Copy link
Contributor Author

It looks good to me 🙏

Could you please update the flutter_search sample as well? It seems that the builder signature has been changed (with the addition of child param).

  error • The argument type 'Scaffold Function(BuildContext, SearchState)' can't be assigned to the parameter type 'ValueStreamWidgetBuilder<SearchState>'.  • lib/search_screen.dart:50:16 • argument_type_not_assignable

I did it and added support for macOS. It had some issues when running it.

Copy link
Collaborator

@hoc081098 hoc081098 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your hard work 👍 ! The CI failed, but I'll fix it in another PR 🙏.

@hoc081098 hoc081098 merged commit f3c39ca into ReactiveX:master Feb 1, 2025
1 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add ValueStreamListener and ValueStreamConsumer widgets
2 participants