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

Stream controller providing stale values for onModelReady() #129

Open
omkardeshpande3194 opened this issue May 12, 2021 · 2 comments
Open

Comments

@omkardeshpande3194
Copy link

I followed the pattern you suggested in provider-aechitecture-pt2

The flow is common as follows, login view gets user credentials , passes to login view model which then passes to auth service. After api call is successful auth service adds user to user stream controller and then on login success navigator.pushNamed()
Which pushes to homeview

ref - https://github.com/FilledStacks/flutter-tutorials/blob/master/012-provider-architecture-pt2/2-final/lib/ui/views/home_view.dart

onModelReady: (model) => model.loadData(Provider.of(context))

The issue I am facing is that the stream controller doesn't pass the user before model.loadData() is called for homeview. After reading a few articles I got to know that there is no way to ensure if streams deliver data. Am I missing something? how can I solve this issue?

Not sure if this is the right place to ask this question

@omkardeshpande3194
Copy link
Author

I guess we should be pulling user from some UserService in the home model loadData( ) method. As we cannot rely on pushed data (doesn't assure delivery) but we can wait and listen for data form user service in home model.

@FilledStacks
Copy link
Owner

@omkardeshpande3194 provider was updated quite a bit after this tutorial. I think you need to set lazy false for the StreamProvider for this to work.

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

No branches or pull requests

2 participants