<!--
{
  "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/Publishers/ReplaceEmpty",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Combine"
    ],
    "preciseIdentifier" : "s:7Combine10PublishersO12ReplaceEmptyV"
  },
  "title" : "Publishers.ReplaceEmpty"
}
-->

# Publishers.ReplaceEmpty

A publisher that replaces an empty stream with a provided element.

```
struct ReplaceEmpty<Upstream> where Upstream : Publisher
```

## Topics

### Creating a replace empty publisher

[`init(upstream:output:)`](/documentation/Combine/Publishers/ReplaceEmpty/init(upstream:output:))

Creates a publisher that replaces an empty stream with a provided element.

### Declaring supporting types

[`Publishers.ReplaceEmpty.Output`](/documentation/Combine/Publishers/ReplaceEmpty/Output-swift.typealias)

The kind of values published by this publisher.

[`Publishers.ReplaceEmpty.Output`](/documentation/Combine/Publishers/ReplaceEmpty/Output-swift.typealias)

The kind of values published by this publisher.

[`Publishers.ReplaceEmpty.Failure`](/documentation/Combine/Publishers/ReplaceEmpty/Failure)

The kind of errors this publisher might publish.

### Inspecting publisher properties

[`upstream`](/documentation/Combine/Publishers/ReplaceEmpty/upstream)

The publisher from which this publisher receives elements.

[`output`](/documentation/Combine/Publishers/ReplaceEmpty/output-swift.property)

The element to deliver when the upstream publisher finishes without delivering any elements.

[`output`](/documentation/Combine/Publishers/ReplaceEmpty/output-swift.property)

The element to deliver when the upstream publisher finishes without delivering any elements.

### Comparing publishers

[`==(_:_:)`](/documentation/Combine/Publishers/ReplaceEmpty/==(_:_:))

Returns a Boolean value that indicates whether two publishers are equivalent.



---

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)