---
title: Optional.Publisher
framework: swift
role: symbol
role_heading: Structure
path: swift/optional/publisher-swift.struct
---

# Optional.Publisher

The type of a Combine publisher that publishes the value of a Swift optional instance to each subscriber exactly once, if the instance has any value at all.

## Declaration

```swift
struct Publisher
```

## Overview

Overview In contrast with the Just publisher, which always produces a single value, this publisher might not send any values and instead finish normally, if output is nil.

## Topics

### Declaring Publisher Topography

- [Optional.Publisher.Output](swift/optional/publisher-swift.struct/output-swift.typealias.md)
- [Optional.Publisher.Failure](swift/optional/publisher-swift.struct/failure.md)

### Creating an Optional Publisher

- [init(_:)](swift/optional/publisher-swift.struct/init(_:).md)

### Inpsecting Publisher Properties

- [output](swift/optional/publisher-swift.struct/output-swift.property.md)

### Working with Subscribers

- [receive(subscriber:)](swift/optional/publisher-swift.struct/receive(subscriber:).md)

### Instance Methods

- [allSatisfy(_:)](swift/optional/publisher-swift.struct/allsatisfy(_:).md)
- [collect()](swift/optional/publisher-swift.struct/collect().md)
- [compactMap(_:)](swift/optional/publisher-swift.struct/compactmap(_:).md)
- [contains(_:)](swift/optional/publisher-swift.struct/contains(_:).md)
- [contains(where:)](swift/optional/publisher-swift.struct/contains(where:).md)
- [count()](swift/optional/publisher-swift.struct/count().md)
- [drop(while:)](swift/optional/publisher-swift.struct/drop(while:).md)
- [dropFirst(_:)](swift/optional/publisher-swift.struct/dropfirst(_:).md)
- [filter(_:)](swift/optional/publisher-swift.struct/filter(_:).md)
- [first()](swift/optional/publisher-swift.struct/first().md)
- [first(where:)](swift/optional/publisher-swift.struct/first(where:).md)
- [ignoreOutput()](swift/optional/publisher-swift.struct/ignoreoutput().md)
- [last()](swift/optional/publisher-swift.struct/last().md)
- [last(where:)](swift/optional/publisher-swift.struct/last(where:).md)
- [map(_:)](swift/optional/publisher-swift.struct/map(_:).md)
- [max()](swift/optional/publisher-swift.struct/max().md)
- [max(by:)](swift/optional/publisher-swift.struct/max(by:).md)
- [min()](swift/optional/publisher-swift.struct/min().md)
- [min(by:)](swift/optional/publisher-swift.struct/min(by:).md)
- [output(at:)](swift/optional/publisher-swift.struct/output(at:).md)
- [output(in:)](swift/optional/publisher-swift.struct/output(in:).md)
- [prefix(_:)](swift/optional/publisher-swift.struct/prefix(_:).md)
- [prefix(while:)](swift/optional/publisher-swift.struct/prefix(while:).md)
- [reduce(_:_:)](swift/optional/publisher-swift.struct/reduce(_:_:).md)
- [removeDuplicates()](swift/optional/publisher-swift.struct/removeduplicates().md)
- [removeDuplicates(by:)](swift/optional/publisher-swift.struct/removeduplicates(by:).md)
- [replaceEmpty(with:)](swift/optional/publisher-swift.struct/replaceempty(with:).md)
- [replaceError(with:)](swift/optional/publisher-swift.struct/replaceerror(with:).md)
- [retry(_:)](swift/optional/publisher-swift.struct/retry(_:).md)
- [scan(_:_:)](swift/optional/publisher-swift.struct/scan(_:_:).md)

## Relationships

### Conforms To

- [Equatable](swift/equatable.md)
- [Publisher](combine/publisher.md)

## See Also

### Publishing an Optional

- [publisher](swift/optional/publisher-swift.property.md)
