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
Observable.combineLatest2 is not streaming when page is loaded through navigation #223
Comments
Hi there, TL;DR That example is wrong and we need to the author to update it. |
@frankpepermans thank you for your reply. Yes, I understand that the submitValid logic is wrong as it will return true always.
If I have routes configured, the control flow is not reaching to the debug point even when both fields are valid. |
Ok, to figure out what is going on: Can you try to listen to the streams directly and then debug in their respective listen handlers? |
@frankpepermans , yes I tried to listen and it worked perfectly. both
were working and was able to print the data that was streaming. |
After lot of trial, I found that when I used routes for the navigation, flutter will build the page multiple times and thats the expected behavior refer here So when it builds the page multiple times, it was creating multiple Observables on the bloc as it was creating new instance of Bloc every time it creates the Page route. So when I modify the code
it worked perfectly. The other way is to achieve is to create a stateful widget and do the initialization in the init method. |
@pravinarr You mentioned that it can be achieved by creating stateful widget? Do you have sample? I experienced same with yours, when I use home the submitValid is streaming but not if I use routes |
I am creating a flutter app with blocs.
I followed the code available in Flutter login with blocs
It works as expected, if my app has no routes defined
but when I change my app to use routes
bloc code
Observable.combileLatest2 is not streaming the data (but it streams error though).
Using Rxdart version 0.19.0 and
Flutter 1.0.0 • channel beta •https://github.com/flutter/flutter.git Framework • revision 5391447fae (6 days ago) • 2018-11-29 19:41:26-0800 Engine • revision 7375a0f414Tools • Dart 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)
Am I doing something wrong here? thanks in advance
The text was updated successfully, but these errors were encountered: