Skip to content

invalidation forwarding #3675

@TekExplorer

Description

@TekExplorer

Often, we will do something like this:

@riverpod
Task task(Ref ref) => getTask();

@riverpod
String taskName(Ref ref) => ref.watch(taskProvider).name;

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/refresh taskProvider instead.

This request is to define some kind of invalidation forwarding. perhaps something like

@riverpod
String taskName(Ref ref) {
  ref.forwardInvalidation(taskProvider);
  return ref.watch(taskProvider).name;
}

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, since taskNameProvider could dispose for other reasons.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions