Hey Guys,
Thanks a lot for the awesome work that is being done to ship Moya.
Actually i want to discuss with you a feature that came on my mind to extend Moya.
Basically i'm using Alamofire and i used to make a Router that organize my Alamofire API calls. however after i heard about Moya i just checked out the documentation and realized that it's pretty awesome specially for reactive programming and for unit testing. So i said i've to stop and adopt Moya in my Swift projects.
However, I used to do kind of technique called Dependency Inversion Principle (DIP) to make my web service layer more ignorant about the rest of the App. I do that by creating a new layer more abstract like a (protocol) act as a gateway between my app and the service layer(That connect to the network). The service layer eventually implements the gateway protocol. The protocol act as as a contract. The rest of the app can now be ignorant. It knows about the contract but not about any class that satisfy the contract. This makes it easy to replace the marvel service with whatever we want to use for unit testing.
The following Diagram illustrate what i mean:

So i thought since Moya is more like abstraction layer, why not we implement this into Moya to make the rest of the app more ignorant about Moya.
Is that sounds interesting?
P.S. I'd be happy to share some code that i already did for implementing DIP principle with Alamofire framework.
Hey @iSame7, thanks so much for the idea! 馃帀 Seems really fun!
Although _I'm not sure_ if it would fit in current core of Moya, I would love to see it _at least_ as some sort of extension. What do you think about that?
Also, anyone else from @Moya/contributors could take a look? 馃惣
I'd love to see a working example, I've been working on something similar, but unfortunately I can't get away from the singleton object for making requests, which results in a lot of API.request(target: MoyaTarget) calls around
Hi @iSame7, can you share the code for better explaining?
I create a protocol for my network calls wraps my methods of my target. Then I inject them into my view models using Swinject. This way my objects have no idea what they are interfacing with just that it conforms to a service or network type. Sounds similar to what you are doing.
@iSame7 would it be possible to look at your code? I'm not sure if this is the right abstraction layer to institute this, but even if it doesn't belong in Moya, I'd love to add documentation around it. Please let us know :+1:
Closing this for now. @iSame7, please reopen a new issue if you think there is an opportunity to improve the documentation around abstracting Moya.
Most helpful comment
I'd love to see a working example, I've been working on something similar, but unfortunately I can't get away from the singleton object for making requests, which results in a lot of
API.request(target: MoyaTarget)calls around