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

# Publishers.FlatMap

A publisher that transforms elements from an upstream publisher into a new publisher.

```
struct FlatMap<NewPublisher, Upstream> where NewPublisher : Publisher, Upstream : Publisher, NewPublisher.Failure == Upstream.Failure
```

## Topics

### Creating a flat map Publisher

[`init(upstream:maxPublishers:transform:)`](/documentation/Combine/Publishers/FlatMap/init(upstream:maxPublishers:transform:))

Creates a publisher that transforms elements from an upstream publisher into a new publisher.

### Declaring supporting types

[`Publishers.FlatMap.Output`](/documentation/Combine/Publishers/FlatMap/Output)

The kind of values published by this publisher.

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

The kind of errors this publisher might publish.

### Inspecting publisher properties

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

The publisher from which this publisher receives elements.

[`maxPublishers`](/documentation/Combine/Publishers/FlatMap/maxPublishers)

The maximum number of concurrent publisher subscriptions

[`transform`](/documentation/Combine/Publishers/FlatMap/transform)

A closure that takes an element as a parameter and returns a publisher that produces elements of that type.



---

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)