Created
November 13, 2017 03:18
-
-
Save koromiko/1ef41d1d7d87beac22eaf4cc4a38ec69 to your computer and use it in GitHub Desktop.
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
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