Created
January 23, 2018 01:51
-
-
Save fabiothiroki/53c82061eaaaec6aed538cc3c58c28ac to your computer and use it in GitHub Desktop.
NearbyPlaces Service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct NearbyPlacesService { | |
private let placesDatasource: PlacesDatasource | |
private let userLocationDatasource: UserLocationDatasource | |
init(userLocationDatasource: UserLocationDatasource, | |
placesDatasource: PlacesDatasource) { | |
self.userLocationDatasource = userLocationDatasource | |
self.placesDatasource = placesDatasource | |
} | |
func fetchNearbyPlaces() -> Observable<LocationPlaces> { | |
return userLocationDatasource.getUserLocation() | |
.flatMap({ (userLocation: CLLocation) -> Observable<LocationPlaces> in | |
return self.placesDatasource.placesAround(latitude: userLocation.coordinate.latitude, | |
longitude: userLocation.coordinate.longitude) | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment