Skip to content

Commit

Permalink
Update Promise+Async
Browse files Browse the repository at this point in the history
  • Loading branch information
mlch911 committed May 16, 2023
1 parent 316ae95 commit 1c0a445
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Sources/Promises/Promise+Async.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ public extension Promise {
}
}

public extension Task {
func asPromise() -> Promise<Success> {
Promise<Success> { fulfill, reject in
fulfill(try await self.value)
}
}
}

@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
public extension Promise {
typealias SwiftAsync = (@escaping (Value) -> Void, @escaping (Error) -> Void) async throws -> Void
Expand Down

0 comments on commit 1c0a445

Please sign in to comment.