cached_query icon indicating copy to clipboard operation
cached_query copied to clipboard

Integrating with Riverpod

Open chimon2000 opened this issue 1 year ago • 1 comments

It would be nice to have some documentation on integrating with Riverpod. I have a simple stream provider that ingests a function that returns a query stream and maps the result.

final todoProvider = StreamProvider.autoDispose<GetTodoResponse>(
  (ref) async* {
    ...
    await for (var element in todoService.get()) {
      if (element.data != null) yield element.data!;
      if (element.status == QueryStatus.success) yield element.data!;
    }
  },
);

It's not completely obvious how I would want to map the different states.

chimon2000 avatar Jan 02 '25 06:01 chimon2000