---
title: Subscriber
framework: combine
role: symbol
role_heading: Protocol
path: combine/subscriber
---

# Subscriber

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

## Declaration

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

## Mentioned in

Processing Published Elements with Subscribers Receiving and Handling Events with Combine Controlling Publishing with Connectable Publishers Using Combine for Your App’s Asynchronous Code

## Overview

Overview A Subscriber instance receives a stream of elements from a Publisher, along with life cycle events describing changes to their relationship. A given subscriber’s Input and Failure associated types must match the Output and Failure of its corresponding publisher. You connect a subscriber to a publisher by calling the publisher’s subscribe(_:) method.  After making this call, the publisher invokes the subscriber’s receive(subscription:) method. This gives the subscriber a 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(_:), possibly asynchronously, to deliver newly-published elements. If the publisher stops publishing, it calls receive(completion:), using a parameter of type Subscribers.Completion to indicate whether publishing completes normally or with an error. Combine provides the following subscribers as operators on the Publisher type: sink(receiveCompletion:receiveValue:) executes arbitrary closures when it receives a completion signal and each time it receives a new element. 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](combine/subscriber/input.md)
- [Failure](combine/subscriber/failure.md)

### Receiving elements

- [receive(_:)](combine/subscriber/receive(_:).md)
- [receive()](combine/subscriber/receive().md)

### Receiving life cycle events

- [receive(subscription:)](combine/subscriber/receive(subscription:).md)
- [receive(completion:)](combine/subscriber/receive(completion:).md)
- [Subscribers.Completion](combine/subscribers/completion.md)

## Relationships

### Inherits From

- [CustomCombineIdentifierConvertible](combine/customcombineidentifierconvertible.md)

### Conforming Types

- [AnySubscriber](combine/anysubscriber.md)
- [Subscribers.Assign](combine/subscribers/assign.md)
- [Subscribers.Sink](combine/subscribers/sink.md)

## See Also

### Subscribers

- [Processing Published Elements with Subscribers](combine/processing-published-elements-with-subscribers.md)
- [Subscribers](combine/subscribers.md)
- [AnySubscriber](combine/anysubscriber.md)
- [Subscription](combine/subscription.md)
- [Subscriptions](combine/subscriptions.md)
