Skip to content

Instantly share code, notes, and snippets.

@dmytro-anokhin
Last active December 10, 2019 21:18
Show Gist options
  • Save dmytro-anokhin/5ff89967ba31484f948e36208c97db1a to your computer and use it in GitHub Desktop.
Save dmytro-anokhin/5ff89967ba31484f948e36208c97db1a to your computer and use it in GitHub Desktop.
protocol DataProvider {
func fetchPosts(withURL url: URL, completion: @escaping (Result<[Post], Error>) -> Void)
func fetchUser(withId id: Int, completion: @escaping (User?) -> Void)
}
struct PostView: View {
let dataProvider: DataProvider
init(dataProvider: DataProvider) {
self.dataProvider = dataProvider
}
var body: some View {
// ...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment