hmlongco / Resolver

Swift Ultralight Dependency Injection / Service Locator framework
MIT License
2.14k stars 188 forks source link

Possible error in documentation (`XYZService` and `XYZCombinedService`) #94

Closed phi161 closed 3 years ago

phi161 commented 3 years ago

First of all, thank you for this great library and for the effort to provide detailed Documentation, I find it extremely helpful!

In this section of the Introduction, the docs say:

The XYZService, in turn, needs a reference to an XYZSessionService to do its job.

but later in the code sample:

class XYZCombinedService: XYZFetching, XYZUpdating {
    private var session: XYZSessionService
    init(_ session: XYZSessionService) {
        self.session = session
    }
    // Implmentation
}

struct XYZService {
    // Implmentation
}

Am I missing something here, or XYZViewModel should depend on XYZCombinedService instead of XYZService?

hmlongco commented 3 years ago

Did a quick update to the documentation.

The XYZViewModel needs an instance of an object that implements a XYZFetching protocol, one that implements XYZUpdating, and the view model also wants access to a XYZService for good measure.

So XYZViewModel wants references to three objects. But in our code, XYZCombinedService implements both the XYZFetching and the XYZUpdating protocols in the same class. Not to mention that XYZCombinedService also has its own dependency, and needs a reference to an XYZSessionService to do its job.

The code makes those dependencies clear.

phi161 commented 3 years ago

I understand now! Thanks a lot for the prompt reply!