Created
December 10, 2019 21:14
-
-
Save dmytro-anokhin/3f5ee0452d9fa230690c0cdc045d961a to your computer and use it in GitHub Desktop.
This file contains hidden or 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 PostsDataProviderA: DataProvider { | |
let networkService: NetworkingA | |
let userService: UserService | |
func fetchPosts(withURL url: URL, completion: @escaping (Result<[Post], Error>) -> Void) { | |
networkService.loadJSON(withURL: url, type: [Post].self, completion: completion) | |
} | |
func fetchUser(withId id: Int, completion: @escaping (User?) -> Void) { | |
userService.getUser(withId: id, completion: completion) | |
} | |
} | |
struct PostsDataProviderB: DataProvider { | |
let networkService: NetworkingB | |
let userService: UserService | |
func fetchPosts(withURL url: URL, completion: @escaping (Result<[Post], Error>) -> Void) { | |
networkService.load(url, type: [Post].self, completion: completion) | |
} | |
func fetchUser(withId id: Int, completion: @escaping (User?) -> Void) { | |
userService.getUser(withId: id, completion: completion) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment