Skip to content

Instantly share code, notes, and snippets.

@tieleman
Last active August 4, 2020 09:32
Show Gist options
  • Save tieleman/66cf340bf40d6601b07e0e66aed7ef42 to your computer and use it in GitHub Desktop.
Save tieleman/66cf340bf40d6601b07e0e66aed7ef42 to your computer and use it in GitHub Desktop.
protocol AuthorServiceProtocol {
func fetchAllAuthors() -> [Author]
}
class AuthorWebService: AuthorServiceProtocol {
func fetchAllAuthors() -> [Author] {
// fetch and return authors
}
}
class AuthorViewModel {
private let service : AuthorServiceProtocol
init(service: AuthorServiceProtocol = AuthorWebService()) {
self.service = service
}
func allAuthors() -> [Author] {
service.fetchAllAuthors()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment