Future Type at WWDC 2019 721 Combine in Practice


I want to use the new Publisher Types of the new Combine Framework of iOS 13.

In the session 721 of WWDC 2019 Combine in Practice at about 31:00 or slide 214 Apple uses the type Future. But currently, there is no Future Type in the Standard Library. What kind of type do they used to implement an async (network) task in combination with Publisher?

Example from the WWDC slides:

/// network task
func usernameAvailable(_ username: String, completion: (Bool) -> Void)

@Published var username: String = ""

var validatedUsername: AnyPublisher<String?, Never> {
    return $username
           .flatMap { username in
               return Future { promise in
               // promise: (Result<Output, Failure>) -> Void
                  self.usernameAvailable(username) { available in
                        promise(.success(available ? username : nil))
1 Like

I wonder if that's supposed to be Publishers.Future: https://developer.apple.com/documentation/combine/publishers/future

1 Like

Yeah, you are right. Thank you!
I thought of Future from Async/await :)

Terms of Service

Privacy Policy

Cookie Policy