Skip to content

Instantly share code, notes, and snippets.

@SebastianBoldt
Last active February 4, 2022 11:17
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 SebastianBoldt/eaf089804efec8da852779b4f882a954 to your computer and use it in GitHub Desktop.
Save SebastianBoldt/eaf089804efec8da852779b4f882a954 to your computer and use it in GitHub Desktop.
enum TaskData {
@TaskLocal static var userId: Int?
}
Task {
await TaskData.$userId.withValue(786) {
let task = Task {
print(TaskData.userId ?? "No User Id")
}
print(TaskData.userId ?? "No User Id")
}
await TaskData.$userId.withValue(234) {
let task = Task {
print(TaskData.userId ?? "No User Id")
}
print(TaskData.userId ?? "No User Id")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment