Skip to content

Dependency Injection/Inversion, DDD, and Clean Code with Riverpod #3549

Answered by snapsl
matthew-nm asked this question in Q&A
Discussion options

You must be logged in to vote

Usually, DI in riverpod works like any other provider. Just to give an option.

@riverpod
IAuthFacade authFacade(AuthFacadeRef ref) => throw UnimplementedError();
// In "main" or where required
ProviderScope(
overrides: [authFacadeProvider.overrideWithValue(concreteAuthImpl)]
child: ...
)

For testing replace concreteAuthImpl with mock.
But maybe I am missing something.

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
2 replies
@matthew-nm
Comment options

@snapsl
Comment options

Answer selected by matthew-nm
Comment options

You must be logged in to vote
2 replies
@snapsl
Comment options

@gdurandrexel
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants