nalexn / clean-architecture-swiftui

SwiftUI sample app using Clean Architecture. Examples of working with CoreData persistence, networking, dependency injection, unit testing, and more.
MIT License
5.56k stars 671 forks source link

bgQueue is unused in WebRepository #47

Closed guillevc closed 3 years ago

guillevc commented 3 years ago

Hello, I've just started digging in this project and I found that the bgQueue defined in WebRepository isn't used.

Is there something I'm missing or it isnt really necessary to define bgQueue in the protocol?

nalexn commented 3 years ago

Hey @guillevc

There are a couple of places where it is used, though you're right, most of the WebRepositories don't use it.

The intent of bgQueue is for dispatching the work related to parsing the HTTP response or doing some other heavy operation (resizing the downloaded image) before returning the control back to the main thread.

In theory, every WebRepository should always use BG thread for its utility operations.

I cannot say I intentionally omitted to dispatch the parsing to the BG for some repos, though since the payload is lightweight it can be parsed in the main thread (this can even be more efficient than dispatch to BG and back to main).

guillevc commented 3 years ago

Thanks for the reply and for all the work put into this project. 👏