Summary
We kicked off this chapter by revisiting the architecture of our Recipes! app to include repositories. This addition was aimed at adhering to the principle of SoC and minimizing our app’s dependency on the API itself. We also introduced the Result
object, a transformative component in our error-handling strategy. This single object encapsulates both success and failure states, making our ViewModels more robust and intelligible. By using the Result
object, we’ve made it easier to handle anticipated errors in a graceful manner, while still keeping exceptions reserved for critical failures.
After setting this architectural foundation, we moved on to explore the power and simplicity of Refit, a type-safe REST client. Refit has substantially streamlined the way we interact with APIs, making the code more readable and maintainable.
We also looked at how the Result
object elegantly fits into our ViewModels, making it far easier to handle expected errors and providing...