<!--
{
  "availability" : [
    "iOS: 14.0.0 -",
    "iPadOS: 14.0.0 -",
    "macCatalyst: 14.0.0 -",
    "macOS: 11.0.0 -",
    "tvOS: 14.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 7.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Combine",
  "identifier" : "/documentation/Combine/Publisher/flatMap(maxPublishers:_:)-qxf",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Combine"
    ],
    "preciseIdentifier" : "s:7Combine9PublisherPAAs5NeverO7FailureRtzrlE7flatMap13maxPublishers_AA0H0O04FlatF0Vy_qd__AK03SetD4TypeVy_xAFQyd__GGAA11SubscribersO6DemandV_qd__6OutputQzctAaBRd__lF"
  },
  "title" : "flatMap(maxPublishers:_:)"
}
-->

# flatMap(maxPublishers:_:)

Transforms all elements from an upstream publisher into a new publisher up to a maximum number of publishers you specify.

```
func flatMap<P>(maxPublishers: Subscribers.Demand = .unlimited, _ transform: @escaping (Self.Output) -> P) -> Publishers.FlatMap<P, Publishers.SetFailureType<Self, P.Failure>> where P : Publisher
```

## Parameters

`maxPublishers`

Specifies the maximum number of concurrent publisher subscriptions, or [`unlimited`](/documentation/Combine/Subscribers/Demand/unlimited) if unspecified.

`transform`

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

## Return Value

A publisher that transforms elements from an upstream  publisher into a publisher of that element’s 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)