I'm trying to remove my dependency on RxAlamofire.
I currently have this function:
func requestData(_ urlRequest: URLRequestConvertible) -> Observable<(HTTPURLResponse, Data)> {
RxAlamofire.request(urlRequest).responseData()
}
How can I refactor this and use Alamofire directly to build and return an RxSwift Observable?
I suggest you look at the way the library wraps URLRequest to get an idea on how to do it...
Below is an abbreviated example from the library. In essence, you need to use
Observable.create
, make the network call passing in a closure that knows how to use the observer thatcreate
gives you.Make sure you send a completed when done and make sure the disposable knows how to cancel the request.
Your
Base
will be something in Alamofire (I don't use Alamofire so I'm not sure what that might be.)