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
Coverage of Riverpod's Providers #3
Comments
Hello!
You can wrap The names creator/emitter/watcher are different from providers, so there are minimum name conflicts. However, the name
In a summary, use Emitter for anything with
Firstly, use the extension methods. Since there are only two types of creators, extension methods ( Second, compose multiple creators with Let me know if you have any questions or thoughts! Thanks! |
To be honest, I migrated my own project from riverpod to creator in a few hours, but it was a full migration, so I didn't have an experience that they co-exist in a project. Let me know if you see issues. |
Thank you very much for your explanations. |
One thing I forgot to mention is that remember riverpod is default to keep alive while creator is default to auto dispose. |
I've seen that. That's why i use Riverpod's autoDispose feature for all my stream providers and see some issues there with disposing and relistening. |
In my project my view models have quite some provider listeners like this:
Passing a Ref instance is no problem, but how do i listen to a stream provider in there? |
(typing on phone with wine) I guess the answer depends on what do you do inside those listener. If it has side effects which doesn't change the view model property, I think you can pull the logic out and create a separate |
Hmmmm, but using a Watcher means we are in the view.
How can i react to incoming stream changes in the view model? |
Sorry if I was clear earlier. I'm assuming you want to do something with the previous and current value of
Then you just need to watch the
Or add a Watcher at somewhere:
Hope this makes more sense. |
That makes all sense, yes, but i still don't know how to listen to the stream creator within my view model and react to changes in there.
I.e. directly use the passed Ref object and listen to a stream provider and use a callback to handle the updated data in the next object. |
Creator doesn't have a My point was if If |
_handleContractorAccountsUpdate does update a property in ViewModel and a corresponding view is watching it as a ConsumerWidget - and yes, ViewModel uses ChangeNotifier, the one that is not supported with Creator and not encouraged to use with Riverpod. But for my needs it works best.
|
Try something like this. I think it is because
|
This should work:
Prints:
|
Yep that works fine now. Thank you so much for your support!
When switching to another view i would assume that all used providers are disposed (what your doc also says), but this is not the case. Everything seems to work as if i never had left the first view, i.e. there is also no print output in doSomethingCreator. |
Ok great, this seems to do the trick:
|
That works, but I would do this, which is simpler and can use StatelessWidget.
|
Even better :-) |
So have you finished migration, how is your experience with creator so far? If there is no other issue, I will close this. |
Well it was just a small part of my current mobile app to see if the migration would work. |
Hi there,
i'm looking forward to test Creator in a new mobile app.
Since the naming is quite different and there are actually only Creator and Emitter around i wonder if this package covers all different types of Providers and cases which Riverpod offers?
Since the app has to be wrapped with CreatorGraph i have my doubts that Riverpod and Creator can be used side by side in the same app.
If that's the case it would be interesting to see a section in your documentation "Migrating from Riverpod" which shows how the various provider usages would look with Creator.
Thanks for offering the package. Making state management easier is always a good task - and i've also discovered some flaws when using Riverpod.
The text was updated successfully, but these errors were encountered: