Skip to content

Instantly share code, notes, and snippets.

@azamsharp
Last active October 10, 2019 18:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save azamsharp/74e62b843b9e9cc3c4d9de2fe0493b7e to your computer and use it in GitHub Desktop.
Save azamsharp/74e62b843b9e9cc3c4d9de2fe0493b7e to your computer and use it in GitHub Desktop.
struct Post {
let id = UUID().uuidString
let title: String
let body: String
}
class Webservice {
func fetchPosts(completion: @escaping ([Post]) -> Void) {
DispatchQueue.main.asyncAfter(deadline: .now() + 2.0) {
// fetch from a web api and then populate the Post array
let posts = [
Post(title: "Hello SwiftUI", body: "Learn to create your first SwiftUI App!"),
Post(title: "Getting started with Combine", body: "Introduce reactive programming using Combine framework")
]
completion(posts)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment