Dependency injection strategy in a multi-layered application #182
Unanswered
razvanbenga89
asked this question in
Q&A
Replies: 1 comment 5 replies
-
Hi @razvanbenga89, your approach of passing dependencies to dependencies can work just fine. It's just a very explicit way of doing dependencies. If you use the |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello everyone!
I was following your series on protocol witnesses and dependency injection and I really love the approach you've taken. It feels really easy to mock clients and test view models with this approach. My question is related on how to apply these concepts in a multi layered system. For instance, I might have a client or usecase that might reference a repository, which, in turn, might reference an apiclient and a datatbaseservice. I'm interested on how I can achieve this and also test the integration between repo, apiclient and dbservice. What came to mind was maybe doing something like this:
I was thinking that this way we could use live(apiClient: .test, dbService: .test) inside our tests. Does this look like a good approach? Could we achieve this using the @dependency property wrapper as well? Thanks
Beta Was this translation helpful? Give feedback.
All reactions