Skip to content

Instantly share code, notes, and snippets.

@SebastianBoldt
Last active January 30, 2022 10:07
Show Gist options
  • Save SebastianBoldt/a76ca2d614927202450c9bd47403244b to your computer and use it in GitHub Desktop.
Save SebastianBoldt/a76ca2d614927202450c9bd47403244b to your computer and use it in GitHub Desktop.
enum SomeError: Error {
case foo
}
func completionFunction(completion: @escaping ([Data], error: @escaping (Error) -> Void) -> Void) {
getData(complete: completion)
}
func asyncFunctionWrapper() async -> Data {
await withCheckedThrowingContinuation { continuation in
completionFunction(completion: { data in
continuation.resume(returning: data)
} error: {
contiuation.resume(throwing: SomeError.foo)
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment