riverpod icon indicating copy to clipboard operation
riverpod copied to clipboard

docs(example): add a simple grocery list app example that uses local persistence

Open thisissandipp opened this issue 11 months ago • 4 comments

Describe what scenario you think is uncovered by the existing examples/articles

Many applications require persistent data storage alongside reactive data management. While Riverpod simplifies working with futures and streams, a comprehensive example that demonstrates using Riverpod for handling and managing locally stored entities (for example groceries, todos, or bookmarks) is missing in the docs.

Describe why existing examples/articles do not cover this case

The existing example around todo explains how to use NotifierProvider and StateNotifier. I'd say it's basic, limited to in-memory states, and does not cover combining Riverpod with storage solutions like SharedPreferences.

Additional context

How about an example grocery list application (as there is already a todos example)? It can have the following features

  • add a grocery item to the list (which will eventually be stored in the local storage)
  • read all the added grocery items (a stream that returns a list of items from storage)
  • make an item as bought/completed (updates and persists updated state)
  • remove/delete an item
  • add a filter (to buy, already bought, bought in the past week, etc)

thisissandipp avatar Jan 14 '25 20:01 thisissandipp

I'd rather not add a persistence example until I complete the persistence feature in Riverpod.

Once we have it, we can update the existing examples to use persistence.

rrousselGit avatar Jan 14 '25 21:01 rrousselGit

Cool, I didn't know about this - definitely sounds exciting.

How about a Firebase login example? It can showcase integrating other packages, managing authentication states with streams, error handling/displaying error messages, and dynamic view switches based on users' auth states.

This could demonstrate a real-world use case. Additionally, I think the docs should include tutorials instead of direct links to the example repository. The docs explain everything topic by topic, but a structured tutorial would make it easier for beginners and intermediate devs to follow along and learn important topics.

Here are some libraries that have included their examples as a form of tutorials

What do you think about it?

thisissandipp avatar Jan 15 '25 18:01 thisissandipp

Sure. That's a quite different topic from local persistence though

rrousselGit avatar Jan 15 '25 20:01 rrousselGit

You are right. I should have created a separate issue for this topic. Let me go ahead and do that so that we can keep the discussions focused.

Let me know how you’d like to proceed with the current issue - whether to keep it as a placeholder for future persistence examples or handle it differently.

thisissandipp avatar Jan 15 '25 21:01 thisissandipp