-
-
Notifications
You must be signed in to change notification settings - Fork 971
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
How to listen to Provider assignment not Provider value change #3870
Comments
Are you looking for ref.watch? class ProgressNotifier extends Notifier<int> {
@override
int build() {
ref.watch(batchSizeProvider);
return 0;
}
} |
I did try with ref.listen instead of ref.watch because I might want to call some other function instead of just resetting. But I think ProgressNotifier is lazy build so the listen happens only if it has been evaluated first. Can we force ProgressNotifier to build when batchSizeProvider is build so it can listen to it as soon as available ? |
Let me guess: Your UI never listens to Providers rebuild only if they are in use. |
@rrousselGit if I call |
@rrousselGit also, if a provider listen to another provider and the info it carries is not shown on the screen, I don't think it's safe to assume that the provider no longer needed. showing it's value in a later stage would result in a wrong value. Let's imagine a provider that tracks how many times another provider changed and displays it on another screen. if you don't listen when you are not displayed, how are things supposed to work here? |
What is the proper way to modify
ProgressNotifier
to listen tobatchSizeProvider
and to reset itself whenBatchSizeNotifier
changes, rather than letBatchSizeNotifier
call the reset function?Is there any documentation about how to properly listen to providers from other Notifiers?
(it not maybe create one)
The text was updated successfully, but these errors were encountered: