Replies: 1 comment
-
It's just a safeguard to catch typical mistakes. You're free to do: final _locationProvider = Provider.autoDispose((ref) {
ref.keepAlive();
if (ref.watch(demoModeProvider)) {
return ref.watch(simulatedLocationProvider);
} else {
return ref.watch(_gpsProvider);
}
}); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Based on this discussions answer #711, then conditionally depending on providers is valid. Therefore it seems unreasonable to me, that I cannot depend on AutoDisposeProviders from AlwaysAliveProviders.
Consider the following use case:
where simulatedLocationProvider would be an AutoDispose provider and GPSProvider would be an alwaysAliveProvider. I would like for the GPSProvider to keep track of the current location, so if the user leaves demo mode there would not be any delay. There would be keepAlive() option from _gpsProvider, but that would mean that I would convert quite a significant portion to my app to AutoDisposeProvider when thats not needed. Currently I have opted for the simulation to keep running if someone activates demo mode once, which is honestly just a waste of resource.
I'm not terrible confident in the argument I made here, so I would like to know if I'm in the wrong.
Otherwise this might be an argument for merging AutoDispose and non-AutoDispose providers to one.: #2576
Beta Was this translation helpful? Give feedback.
All reactions