riverpod
riverpod copied to clipboard
Add dependency injection doc
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.
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.
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?
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.
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.