cached_query
cached_query copied to clipboard
feat: invalidateQueryAndRefetchIfListeners()
First of all great work!
Regarding my issue, I searched ages and dived deep into the framework code on how to be able to invalidate a query and only refetch it, if it actually is used somewhere. Turns out its not possible out of the box so I wrote myself an extension:
extension ExtensionOnQueryBase<T, State extends QueryState<dynamic>> on QueryBase<T, State> {
void invalidateQueryAndRefetchIfListeners()
{
invalidateQuery();
if (hasListener) refetch();
}
}
I know the name is not the best, but explaining people that this is what you want regarding not asking the server to much and still having a nice user experience and it is not shipped within the docs or the framework might be an issue for many people beeing guided in the wrong driection IMO