Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jacobsapps/dce791c7ff981aa0822b597a68175013 to your computer and use it in GitHub Desktop.
Save jacobsapps/dce791c7ff981aa0822b597a68175013 to your computer and use it in GitHub Desktop.
async let user = fetchUser(id: 1)
async let posts = fetchPosts(userId: 1)
async let friends = fetchFriends(userId: 1)
// no suspension yet
// execution kicks off all child tasks immediately
// suspension only happens at the first await
self.user = await user // fetchUser() async
self.posts = try? await posts // fetchPosts() async throws
self.friends = try await friends // fetchFriends() async throws
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment