When using the code for the searchCityName in 12.2,
searchCityName.rx.text.orEmpty
.filter { !$0.isEmpty }
.flatMap { text in
ApiController.shared
.currentWeather(for: text)
.catchErrorJustReturn(.empty)
}
the weather is not updated when entering a search city
However, when I paste in code from the ‘final’ project, it updates as expected. Did I miss doing something up to this point? The final project code below is a lot different and before I go to get to the final set of code, I am wondering if I can get this 12.2 code working first.
final project code reference:
let search = searchCityName.rx
.controlEvent(.editingDidEndOnExit)
.map { self.searchCityName.text ?? "" }
.filter { !$0.isEmpty }
.flatMapLatest { text in
ApiController.shared
.currentWeather(for: text)
.catchErrorJustReturn(.empty)
}
.asDriver(onErrorJustReturn: .empty)
search.map { "\($0.temperature)° C" }
.drive(tempLabel.rx.text)
.disposed(by: bag)
search.map(\.icon)
.drive(iconLabel.rx.text)
.disposed(by: bag)
search.map { "\($0.humidity)%" }
.drive(humidityLabel.rx.text)
.disposed(by: bag)
search.map(\.cityName)
.drive(cityNameLabel.rx.text)
.disposed(by: bag)