<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Combine",
  "identifier" : "/documentation/Combine/Future",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Combine"
    ],
    "preciseIdentifier" : "s:7Combine6FutureC"
  },
  "title" : "Future"
}
-->

# Future

A publisher that eventually produces a single value and then finishes or fails.

```
final class Future<Output, Failure> where Failure : Error
```

## Overview

Use a future to perform some work and then asynchronously publish a single element. You initialize the future with a closure that takes a [`Future.Promise`](/documentation/Combine/Future/Promise); the closure calls the promise with a <doc://com.apple.documentation/documentation/Swift/Result> that indicates either success or failure. In the success case, the future’s downstream subscriber receives the element prior to the publishing stream finishing normally. If the result is an error, publishing terminates with that error.

The following example shows a method that uses a future to asynchronously publish a random number after a brief delay:

```
func generateAsyncRandomNumberFromFuture() -> Future <Int, Never> {
    return Future() { promise in
        DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
            let number = Int.random(in: 1...10)
            promise(Result.success(number))
        }
    }
}
```

To receive the published value, you use any Combine subscriber, such as a [`Subscribers.Sink`](/documentation/Combine/Subscribers/Sink), like this:

```
cancellable = generateAsyncRandomNumberFromFuture()
    .sink { number in print("Got random number \(number).") }
```

### Integrating with Swift Concurrency

To integrate with the `async`-`await` syntax in Swift 5.5, `Future` can provide its value to an awaiting caller. This is particularly useful because unlike other types that conform to [`Publisher`](/documentation/Combine/Publisher) and potentially publish many elements, a `Future` only publishes one element (or fails). By using the [`value`](/documentation/Combine/Future/value-9iwjz) property, the above call point looks like this:

```
let number = await generateAsyncRandomNumberFromFuture().value
print("Got random number \(number).")
```

### Alternatives to Futures

The `async`-`await` syntax in Swift can also replace the use of a future entirely, for the case where you want to perform some operation after an asynchronous task completes.

You do this with the function <doc://com.apple.documentation/documentation/Swift/withCheckedContinuation(isolation:function:_:)> and its throwing equivalent, <doc://com.apple.documentation/documentation/Swift/withCheckedThrowingContinuation(isolation:function:_:)>. The following example performs the same asynchronous random number generation as the `Future` example above, but as an `async` method:

```
func generateAsyncRandomNumberFromContinuation() async -> Int {
    return await withCheckedContinuation { continuation in
        DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
            let number = Int.random(in: 1...10)
            continuation.resume(returning: number)
        }
    }
}
```

The call point for this method doesn’t use a closure like the future’s sink subscriber does; it simply awaits and assigns the result:

```
let asyncRandom = await generateAsyncRandomNumberFromContinuation()
```

For more information on continuations, see the <doc://com.apple.documentation/documentation/Swift/concurrency> topic in the Swift standard library.

## Topics

### Creating a future

[`init(_:)`](/documentation/Combine/Future/init(_:))

Creates a publisher that invokes a promise closure when the publisher emits an element.

[`Promise`](/documentation/Combine/Future/Promise)

A type that represents a closure to invoke in the future, when an element or error is available.

### Accessing the value asynchronously

[`value`](/documentation/Combine/Future/value-9iwjz)

The published value of the future, delivered asynchronously.

[`value`](/documentation/Combine/Future/value-5iprp)

The published value of the future or an error, delivered asynchronously.

## Relationships

### Conforms To

[`Publisher`](/documentation/Combine/Publisher)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)