Last active
August 20, 2020 12:13
-
-
Save dmytro-anokhin/13dc5925f2a1d556abe3eadf38edb9bd 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
import SwiftUI | |
import RemoteContentView | |
struct Post : Codable { | |
var id: Int | |
// ... | |
} | |
struct PostView : View { | |
// ... | |
} | |
struct PostsView : View { | |
var body: some View { | |
let content = DecodableRemoteContent(url: URL(string: "https://jsonplaceholder.typicode.com/posts")!, | |
type: [Post].self) | |
return RemoteContentView(remoteContent: content) { | |
List($0, id: \Post.id) { | |
PostView(post: $0) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment