Lightweight Dependency Injection Using Async Functions
What if we could actually make our code fully testable in a way that doesn’t require us to introduce any new protocols, mocking types, or complicated abstractions? Let’s explore how we could make use of Swift’s new
async/await
capabilities to make that happen.[…]
One thing that’s very neat about the above pattern is that it still lets us keep using our existing
Networking
andProductLoader
code just like before — all that we have to do is to call that code within thereloading
function/closure that we pass into ourProductViewModel
when creating it[…]
Previously: