Last active
December 10, 2019 21:18
-
-
Save dmytro-anokhin/5ff89967ba31484f948e36208c97db1a 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
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