let textSearch = searchInput.flatMap { text in returnApiController.shared.currentWeather(city: text ??"Error") .catchErrorJustReturn(ApiController.Weather.dummy) }
let mapInput = mapView.rx.regionDidChangeAnimated .skip(1) .map { _inself.mapView.centerCoordinate }
let mapSearch = mapInput.flatMap { coordinate in returnApiController.shared.currentWeather(lat: coordinate.latitude, lon: coordinate.longitude) .catchErrorJustReturn(ApiController.Weather.dummy) }
let currentLocation = locationManager.rx.didUpdateLocations .map { locations in return locations[0] } .filter { location in return location.horizontalAccuracy < kCLLocationAccuracyHundredMeters }
let geoInput = geoLocationButton.rx.tap.asObservable() .do(onNext: { self.locationManager.requestWhenInUseAuthorization() self.locationManager.startUpdatingLocation() })
let geoLocation = geoInput.flatMap { return currentLocation.take(1) }
let geoSearch = geoLocation.flatMap { location in returnApiController.shared.currentWeather(lat: location.coordinate.latitude, lon: location.coordinate.longitude) .catchErrorJustReturn(ApiController.Weather.dummy) } let search =Observable.from([geoSearch, textSearch, mapSearch]) .merge() .asDriver(onErrorJustReturn: ApiController.Weather.dummy)