Replies: 1 comment 1 reply
-
|
When reading the documentation, you'll notice that
Regarding your second point —
And for the extension, I think we can do something like: extension WidgetRefX on WidgetRef {
Future<T> readAutoDisposeAsyncNotifierValue<T>(
AutoDisposeAsyncNotifierProvider<AutoDisposeAsyncNotifier<T>, T> provider,
) async {
final sub = listenManual(provider, (_, __) {}, fireImmediately: true);
return read(provider.future).whenComplete(sub.close);
}
} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
As part of this discussion thread #3600 @rrousselGit mentioned - "More specifically, "read" is discouraged on autoDispose providers.". I looked at the officical riverpod documentations and did not find anything like this mentioned. Can someone point out the relevant documentation section to me?
Secondly, if
ref.readis discouraged, then should we useref.watchinstead? This goes against the info point mentioned in this document - https://riverpod.dev/docs/essentials/side_effects. Also since my callback is passed somewhere as a class member variable, the provider is never diisposed. I would prefer usingref.readinstead.And finally, it would be really helpful if someone can help me out with creating an extension similar to
readFuturefrom the discussion, for anAsyncNotifier. I have something like below, but I am not satisfied with it specially since I have so many linter rule ignores.Beta Was this translation helpful? Give feedback.
All reactions