I've inherited an RxSwift project which uses Moya. I have a task to move a request from one backend to another. Both backends have their TargetType
s sets up just fine as they're being used extensively elsewhere.
The original request looked like this:
return accessProvider.rx
.request(request)
.asObservable()
.debug()
.flatMapLatest({ [weak self] (response) -> Observable<Bool> in
//does some processing of the JSON
return just(true)
})
.catchError({ (error) -> Observable<Bool> in
return just(false)
})
This returns just fine and I get the data.
My new request is exactly the same but the only difference is the provider and requests are using the second TargetType
. For this one, the requests never takes place (confirmed with Charles). I have checked the TargetType
and it looks just fine and performing a non-Rx Moya request works fine, so does an Rx request where I subscribe to it.
Why doesn't it work using flatMapLatest?
I'm new to Rx and very new to Moya so any help is appreciated.
Edit: Debug messages for the first provider:
Refresh token -> subscribed
Refresh token -> subscribed
Refresh token -> Event next(Status Code: 200, Data Length: 773)
Second:
Refresh token -> subscribed
Nothing else