Skip to content

Instantly share code, notes, and snippets.

@farhadmpr
Created September 29, 2021 08:19
Show Gist options
  • Save farhadmpr/c2ec432e4e40088df3eafd652fbaee9b to your computer and use it in GitHub Desktop.
Save farhadmpr/c2ec432e4e40088df3eafd652fbaee9b to your computer and use it in GitHub Desktop.
Ambient Context #4
class MapViewModel {
// MARK: - Private Vars
private let locationService: LocationService
private let dateProviderService: DateProviderService
// MARK: - Init
init(locationService: LocationService, dateProviderService: DateProviderService) {
self.locationService = locationService
self.dateProviderService = dateProviderService
}
// MARK: - Methods
func performCriticalBusinessLogic() {
if locationService.isAuthorized() {
// GPS Service Authroized
} else {
// GPS Service not authorized
}
}
func performAnotherCriticalBusinessLogic() {
let currentDate = dateProviderService.date
if currentDate.isOnWeekend() {
// Perform business logic for weekends
} else {
// Perform business logic for week days
}
}
//....
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment