-
-
Notifications
You must be signed in to change notification settings - Fork 969
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
Reduce boiler plate code for "mounted" in the new AsyncNotifier class. #1926
Comments
There is voluntarily no Building your own isn't what you're supposed to do. Instead cancel your async operations on dispose. |
Yes, before opening this issue, I read about it. But you don't always have something you can cancel, for example, in the code I shared, how will I cancel the future |
It's up to your async functions to expose ways to cancel them. CancelableCompleter is one way. Dio's CancelToken is another. The point is, a In the end what you truly want is #1660 which is a broader issue which in part would solve your problem |
@iLoveDocs I don't understand what those object equality checks are for, why don't you just class Foo extends AutoDisposeAsyncNotifier<void> {
bool _mounted = false;
@override
FutureOr<void> build() {
_mounted = true;
ref.onDispose(() => _mounted = false);
}
// ...
} The async operation implementation is not always under your control, and using Is there a technical reason why |
Async operations should probably be canceled on The current situation isn't ideal. But as I said before, that's in the scope of #1660 to fix This probably should be closed in favor of #1660 |
When using
AsyncNotifier
, I always need to write 4 lines of boilerplate code just to check formounted
before updating the state.Describe the solution you'd like
I think
mounted
property should be added toAsyncNotifier
in some way. Maybe add aRiverpod(...)
annotation to silently ignore that error.The text was updated successfully, but these errors were encountered: