Replies: 2 comments 1 reply
-
I think ref.invalidate(providerA) can do the trick if providerB is AutoDispose and is watched only by providerA (it will be destroyed because no more watched, and then rebuilt) |
Beta Was this translation helpful? Give feedback.
1 reply
-
That's fine |
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
-
When a parent provider (
AProvider
) depends on a child provider (BProvider
), any error inBProvider
propagates toAProvider
. However, consumers ofAProvider
have no direct way to refresh/invalidateBProvider
since they only interact withAProvider
.For example:
BProvider
fails due to a network error.AProvider
(which depends onBProvider
) also enters an error state.AProvider
) shows an error and a "Retry" button that triggersref.refresh(aProvider)
.Current Behavior:
Refreshing
AProvider
re-executes its logic but reuses the existing (failed) state ofBProvider
, causingAProvider
to fail again immediately.Example code
Consumers of a parent provider should be able to recover from errors in child providers without explicit knowledge of the dependency chain. A simple
ref.refresh(parentProvider)
should propagate retries to all relevant dependencies.One solution i came up is making
AProvider
a notifier with a member functionretry
which invalidatesBProvider
.Example code
Is there a recommended pattern or planned feature in Riverpod to handle such scenarios more elegantly? A built-in way to cascade retries/invalidations would simplify error recovery in dependent providers significantly.
Beta Was this translation helpful? Give feedback.
All reactions