Created
July 8, 2025 11:23
-
-
Save jacobsapps/6d54d81de5edb9e1f7b526bff9598ac0 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
Task { // parent task 1 | |
// each of these async lets is a child task of parent task 1 | |
async let name = fetchUserName() | |
async let avatar = fetchUserAvatar() | |
try await (name, avatar) | |
} | |
Task { // parent task 2 | |
await withTaskGroup(of: Void.self) { group in | |
for url in urls { | |
// each task added to the group is a child | |
// of parent task 2 | |
group.addTask { | |
try? await fetchItem(from: url) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment