<!--
{
  "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/Subscriber",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "Combine"
    ],
    "preciseIdentifier" : "s:7Combine10SubscriberP"
  },
  "title" : "Subscriber"
}
-->

# Subscriber

A protocol that declares a type that can receive input from a publisher.

```
protocol Subscriber<Input, Failure> : CustomCombineIdentifierConvertible
```

## Overview

A [`Subscriber`](/documentation/Combine/Subscriber) instance receives a stream of elements from a [`Publisher`](/documentation/Combine/Publisher), along with life cycle events describing changes to their relationship. A given subscriber’s [`Input`](/documentation/Combine/Subscriber/Input) and [`Failure`](/documentation/Combine/Subscriber/Failure) associated types must match the [`Output`](/documentation/Combine/Publisher/Output) and [`Failure`](/documentation/Combine/Publisher/Failure) of its corresponding publisher.

You connect a subscriber to a publisher by calling the publisher’s [`subscribe(_:)`](/documentation/Combine/Publisher/subscribe(_:)-4u8kn) method.  After making this call, the publisher invokes the subscriber’s [`receive(subscription:)`](/documentation/Combine/Subscriber/receive(subscription:)) method. This gives the subscriber a [`Subscription`](/documentation/Combine/Subscription) instance, which it uses to demand elements from the publisher, and to optionally cancel the subscription. After the subscriber makes an initial demand, the publisher calls [`receive(_:)`](/documentation/Combine/Subscriber/receive(_:)), possibly asynchronously, to deliver newly-published elements. If the publisher stops publishing, it calls [`receive(completion:)`](/documentation/Combine/Subscriber/receive(completion:)), using a parameter of type [`Subscribers.Completion`](/documentation/Combine/Subscribers/Completion) to indicate whether publishing completes normally or with an error.

Combine provides the following subscribers as operators on the [`Publisher`](/documentation/Combine/Publisher) type:

- [`sink(receiveCompletion:receiveValue:)`](/documentation/Combine/Publisher/sink(receiveCompletion:receiveValue:)) executes arbitrary closures when it receives a completion signal and each time it receives a new element.
- [`assign(to:on:)`](/documentation/Combine/Publisher/assign(to:on:)) writes each newly-received value to a property identified by a key path on a given instance.

## Topics

### Declaring supporting types

[`Input`](/documentation/Combine/Subscriber/Input)

The kind of values this subscriber receives.

[`Failure`](/documentation/Combine/Subscriber/Failure)

The kind of errors this subscriber might receive.

### Receiving elements

[`receive(_:)`](/documentation/Combine/Subscriber/receive(_:))

Tells the subscriber that the publisher has produced an element.

[`receive()`](/documentation/Combine/Subscriber/receive())

Tells the subscriber that a publisher of void elements is ready to receive further requests.

### Receiving life cycle events

[`receive(subscription:)`](/documentation/Combine/Subscriber/receive(subscription:))

Tells the subscriber that it has successfully subscribed to the publisher and may request items.

[`receive(completion:)`](/documentation/Combine/Subscriber/receive(completion:))

Tells the subscriber that the publisher has completed publishing, either normally or with an error.

[`Completion`](/documentation/Combine/Subscribers/Completion)

A signal that a publisher doesn’t produce additional elements, either due to normal completion or an error.

## Relationships

### Conforming Types

[`Assign`](/documentation/Combine/Subscribers/Assign)

[`AnySubscriber`](/documentation/Combine/AnySubscriber)

[`Sink`](/documentation/Combine/Subscribers/Sink)

### Inherits From

[`CustomCombineIdentifierConvertible`](/documentation/Combine/CustomCombineIdentifierConvertible)

---

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)