4

I'm using RxAlamofire to create my observable. I have build the URLRequest. normally with Alamofire we can use like Alamofire.request(urlRequest) but seem with RxAlamofire I can not use RxAlamofire.requet(urlRequest)

Here is my function

func createOrUpdateItem(for id: NSNumber) -> Observable<Item> {

        let testRequest = Router.top.urlRequest

        let test = RxAlamofire.request(testRequest)

    }

Here is the error enter image description here

Seem like RxAlamofire only accept parameter which are URL and URLConvertible . The strange thing is i look through RxAlamofire there are 2 method which accept both URLConvertible and URLRequestConvertible. Anyone has same same issue and how to resolve? I'm asking this because my app use Alamofire Router which is an enum adopt to URLRequestConvertible.

    /**
         Creates an observable of the `Request`.

         - parameter method: Alamofire method object
         - parameter url: An object adopting `URLConvertible`
         - parameter parameters: A dictionary containing all necessary options
         - parameter encoding: The kind of encoding used to process parameters
         - parameter header: A dictionary containing all the addional headers

         - returns: An observable of the `Request`
         */
    public func request(_ method: Alamofire.HTTPMethod, _ url: URLConvertible, parameters: [String : Any]? = default, encoding: ParameterEncoding = default, headers: [String : String]? = default) -> RxSwift.Observable<Alamofire.DataRequest>

    /**
         Creates an observable of the `Request`.

         - parameter URLRequest: An object adopting `URLRequestConvertible`
         - parameter parameters: A dictionary containing all necessary options
         - parameter encoding: The kind of encoding used to process parameters
         - parameter header: A dictionary containing all the addional headers

         - returns: An observable of the `Request`
         */
    public func request(urlRequest: URLRequestConvertible) -> RxSwift.Observable<Alamofire.DataRequest>
halfer
  • 18,701
  • 13
  • 79
  • 158
Lê Khánh Vinh
  • 2,329
  • 4
  • 24
  • 63

0 Answers0