Replies: 1 comment
-
A parameter (disposeDelay) was added on all autoDispose providers for this |
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
-
This discussion follows a similar issue #1081, which is now closed.
I've encountered the situation a few times where I want a provider to auto-dispose but not before navigation has had a chance to kick in. For example, custom logic on screen A wants to wait for an async operation to load a dependency before navigating to screen B, where the loaded dependency is used. This is particularly relevant when the "loading" UI should be shown on screen A, without any interim loading state shown on screen B.
This won't work with an
autoDispose
provider as the provider is disposed of before ScreenB gets a chance to watch the provider. Of course, this can be worked around by not using an auto-disposing provider but that can result in too much memory being used, especially where the provider is part of a family.It might be useful if we could specify a duration that Riverpod should wait before disposing of an auto-disposing provider that is no longer referenced, such as by awaiting
onDispose
(appreciating that that would be a breaking change), or some other mechanism for providing a wait duration.Beta Was this translation helpful? Give feedback.
All reactions