I'm trying to work with RxAlamofire
to wrap a network request result.
My objective is to fire request, handle JSON response and create and Observable that contain either network operation success or any error occur.
In other place I can call the function that create the Observable and subscribe to it and notify user whether it is success or failure with error message.
My implementation is below:
func discoverMovieList(for url: String, withPagg page: Int) -> Observable<Any> {
let requestUrl = "\(url)&page=\(page)"
return RxAlamofire.json(.get, requestUrl)
.map{ jsonResponse in
self.createOrUpdateMoviesList(from: JSON(jsonResponse))
}
}
How can we correct the code and how we call it from other place to notify the result of the process?