You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Imagine a search field with autocompletion. The value in the field is stored in a state variable. It is then passed to a FutureProvider.family, which requests a list of results. Alas, when a search string changes, it builds a new provider, which has its loading state. Resulting in a loading screen after every keypress.
Given this might be a pretty common case for a family provider, I think it might need to be explicitly documented, like for debouncing, so that other people don't fall into the trap of the loading state.
There are ways to circumvent this: abandon the provider altogether, use a non-family provider with a side effect, create a new family provider for the page, not for the search, or cache search results in the page state. Each of those has their drawbacks, the main being, they don't feel very "riverpod".
So, it might need to be solved in the library, or a circumvention method documented.
The text was updated successfully, but these errors were encountered:
First documented in #4066.
Imagine a search field with autocompletion. The value in the field is stored in a state variable. It is then passed to a
FutureProvider.family
, which requests a list of results. Alas, when a search string changes, it builds a new provider, which has its loading state. Resulting in a loading screen after every keypress.Given this might be a pretty common case for a family provider, I think it might need to be explicitly documented, like for debouncing, so that other people don't fall into the trap of the loading state.
Here is a sample code:
There are ways to circumvent this: abandon the provider altogether, use a non-family provider with a side effect, create a new family provider for the page, not for the search, or cache search results in the page state. Each of those has their drawbacks, the main being, they don't feel very "riverpod".
So, it might need to be solved in the library, or a circumvention method documented.
The text was updated successfully, but these errors were encountered: