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

# Publishers.TryReduce

A publisher that applies an error-throwing closure to all received elements and produces an accumulated value when the upstream publisher finishes.

```
struct TryReduce<Upstream, Output> where Upstream : Publisher
```

## Topics

### Creating a try-reduce publisher

[`init(upstream:initial:nextPartialResult:)`](/documentation/Combine/Publishers/TryReduce/init(upstream:initial:nextPartialResult:))

Creates a publisher that applies an error-throwing closure to all received elements and produces an accumulated value when the upstream publisher finishes.

### Declaring supporting types

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

A publisher that publishes elements specified by a range in the sequence of published elements.

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

The kind of errors this publisher might publish.

### Inspecting publisher properties

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

The publisher from which this publisher receives elements.

[`initial`](/documentation/Combine/Publishers/TryReduce/initial)

The initial value provided on the first-use of the closure.

[`nextPartialResult`](/documentation/Combine/Publishers/TryReduce/nextPartialResult)

An error-throwing closure that takes the previously-accumulated value and the next element from the upstream to produce a new value.



---

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)