riverpod icon indicating copy to clipboard operation
riverpod copied to clipboard

Add dependency injection doc

Open snapsl opened this issue 10 months ago • 2 comments

Make riverpod onboarding easier.

A great feature of riverpod is that we can easily implement dependency injection. But this is not described in the documentation.

The documentation should contain:

How-To implement dependency injection using riverpod:

  • provider (singleton)
  • ProviderScope override
  • family (I am not sure if that is desired)
  • testing

If needed, I can contribute to the docs.

snapsl avatar Apr 24 '24 06:04 snapsl

Can you be more specific about what you want here? Riverpod is not a DI package. And there are already docs explaining how to define a provider, override it, and test it.

rrousselGit avatar Apr 24 '24 09:04 rrousselGit

Of course, using riverpod for DI is just a part of it link. And eventually we use the same concepts (provider, override, testing) that are already defined in the documentation.

I thought about creating an exemplary use case maybe a "case study" that shows how to implement it. Dependency injection is such a frequently applied pattern. Why not promote how easy it is to implement using riverpod?

snapsl avatar Apr 24 '24 11:04 snapsl

I'd rather not have a dedicated DI page. Riverpod isn't about DI. It only does DI in small amounts for testing/scoping.

The doc page you linked is out of date. I'd likely remove that mention.

rrousselGit avatar Jul 08 '24 06:07 rrousselGit

That's alright. Is there a certain reason why riverpod should not be used for DI (anymore)? Because I have seen many projects that use riverpod this way and articles that specifically promote it.

snapsl avatar Jul 09 '24 10:07 snapsl