-
-
Notifications
You must be signed in to change notification settings - Fork 153
Need an example of defining an instance which will be rebuild when listening to a Stream of another instance #44
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
Comments
What about using a StreamBuilder? |
I want to provide it everywhere in the app. If wrapping the entire MaterialApp in StreamBuilder that means it will rebuild the whole app when new value emits. If using StreamBuilder in where I need it, it will be too much boilerplate code, not as easy as one line if I can use it with get_it. |
Get_It does not update anything in the UI! You have to register an Object that either publishes an ChangeNotifier or a Stream as a property to signal the UI that it should update. Then you you can use this object as data source at any place of your UI and use their either an StreamBuilder or an AnimatedBuilde (if you choose ChangenNotifiers) I'm not really clear where your problem is. |
What I want is to register an instance that can automatically update its value based on another registered instance's value (a Stream or ChangeNotifier) changes. Then when I use locator<>(), the value of that instance already be updated. As I said, it's like a ProxyProvider. |
I hope the code will describe my problem properly
From the code above, you can see that |
Updates like that are not supported directly from GetIt. Provider has there anotehr philosopie in that it includes some state management whereas get_it is a pure locator. I always recomens to use get_it togeteher with Streams . |
Uh oh!
There was an error while loading. Please reload this page.
I have a service which exposes a Stream, what I want is defining an instance which has a subscription listening to that Stream and rebuilds itself when that Stream emits a new value. This case pretty much the same as using ProxyProvider in Provider package. How do I do it in get_it? An example of code will be much appreciated.
The text was updated successfully, but these errors were encountered: