I am trying to learn RxSwift. I had been using Moya and now want to try my hand at RxSwift. Totally confused.
let popServiceProvider = MoyaProvider<PopRESTService>()
let o1 = popServiceProvider.rx.request(.getPopByCity(city: "London")).asObservable()
let o2 = popServiceProvider.rx.request(.getPopByCity(city: "Tokyo")).asObservable()
let pObservables:[Observable<Response>] = [o1, o2]
let stats: Observable<Response> = Observable.combineLatest(pObservables)
let m = stats.map({ a in
print(a)
})
First I get an error on let stats:
Cannot convert value of type 'Observable<[Response]>' to specified type 'Observable'
am I even going in the right direction?
EDIT:
Even this doesn't work. Never first the subscribe:
wServiceProvider.rx.request(.getWeatherByCity(city: "Chicago"))
.debug()
.map(Weather.self)
.subscribe({ (event) in
switch event {
case let .success(response):
print(response)
case let .error(response):
print(response)
}
})
.disposed(by: self.disposeBag)