-
-
Notifications
You must be signed in to change notification settings - Fork 961
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
invalidation forwarding #3675
Comments
The general solution is to use a notifier and expose a method that invalidates everything you want in it. |
I can understand that, but I now need to remember to use a specific notifier method. I also need a notifier, even if it might not otherwise be necessary. Being able to forward Invalidations would allow us to naiively use ref.invalidate. Currently, it would just rerun the provider itself with the existing dependencies, which ends up being completely pointless for computed values. |
The problem is, there are lots of subtilities with the idea of "when invalidating X, invalidate Y too". For instance:
All of these rely on the "invalidate" mechanism. And it's highly likely that sometimes the answer to those questions is yes, and sometimes it's no, based on the context. So for that purpose, I'd much rather stick to recommending a Notifier with a method. It's flexible, and doesn't involve new APIs (which adds complexity and can be error prone). |
As far as I'm concerned, a dependency change is more of a "dirty" as opposed to an "invalidate" and shouldn't forward A refresh is just an invalidate + read, so I don't see why it wouldn't act the same. Automatic retry should operate on the forwarded one, because that's where the retry actually does anything. All I'm saying is that Invalidations ought to hit the source of truth, and doesn't actually do anything if it invalidates a computed value, since it won't actually change no matter how many times you invalidate it. |
Perhaps simply adding an It doesn't actively encourage the pattern, but it does make it possible |
Our team could also require this or something similar, although async, my use case is the following:
Now in my code I just want to call For this case it would be nice to control the propagation of |
I think having an utility like the one mentioned here can allow us for more flexibility when describing how our providers should behave on invalidation. Although having a |
Often, we will do something like this:
This is great, but now if i wanted to invalidate or refresh
taskNameProvider
to get the latest value, it doesn't actually do anything, since we needed to invalidate/refreshtaskProvider
instead.This request is to define some kind of invalidation forwarding. perhaps something like
which will decrease the overhead on callers, such that they no longer need to know the implementation
the only thing I can think of otherwise would be to do something like
ref.onDispose(() => ref.invalidate(taskProvider))
but that doesn't actually work, sincetaskNameProvider
could dispose for other reasons.The text was updated successfully, but these errors were encountered: