Skip to content

Instantly share code, notes, and snippets.

@gtokman
Last active October 6, 2021 18:16
Show Gist options
  • Save gtokman/e49a33bb8bc8ce57a74d5082ed8b3421 to your computer and use it in GitHub Desktop.
Save gtokman/e49a33bb8bc8ce57a74d5082ed8b3421 to your computer and use it in GitHub Desktop.
struct ContentView: View {
let viewModel: ViewModel
@State var businesses = [Business]()
var body: some View {
NavigationView {
ZStack {
if businesses.isEmpty {
ProgressView("Loading...")
}
List(businesses) { business in
RestaurantCell(business: business)
}
.listStyle(.plain)
.navigationTitle(Text("Restaurants"))
}
}
.task {
do {
let businesses = try
await viewModel
.getBusinesses(for: "restaurants")
self.businesses = businesses
} catch {
// Handle error
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment