Chapter 12 - Using flatMapLatest to transforms a single-use data source into a multi-use Observable

Hello,

I’m working my way through ch 12 and got confused with a piece of code.

let search = searchCityName.rx.text
.filter { ($0 ?? "").characters.count > 0 }
.flatMapLatest { text in
return ApiController.shared.currentWeather(city: text ?? "Error")
    .catchErrorJustReturn(ApiController.Weather.empty)
}
.shareReplay(1)
.observeOn(MainScheduler.instance)

According to details, flatMapLatest is used to make it multi-used observable. However, what confuses me is we’re not dealing with multiple observables here. It’s just a single observable searchCityName.rx.text we’re subscribing to. Please explain. Thanks.

@bontojr Can you please help with this when you get a chance? Thank you - much appreciated! :]

Hi, why flatMapLatest instead of flatMap?

@bontojr Can you please help with this when you get a chance? Thank you - much appreciated! :]