Skip to content

Instantly share code, notes, and snippets.

@koromiko
Created November 13, 2017 03:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koromiko/1ef41d1d7d87beac22eaf4cc4a38ec69 to your computer and use it in GitHub Desktop.
Save koromiko/1ef41d1d7d87beac22eaf4cc4a38ec69 to your computer and use it in GitHub Desktop.
class PhotoListViewModel {
let apiService: APIServiceProtocol
init( apiService: APIServiceProtocol = APIService()) {
self.apiService = apiService
}
func initFetch() {
self.isLoading = true
apiService.fetchPopularPhoto { [weak self] (success, photos, error) in
self?.isLoading = false
if let error = error {
self?.alertMessage = error.rawValue
} else {
self?.processFetchedPhoto(photos: photos)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment