# Chapter 2: Custom Subscriber

**URL:** <https://forums.kodeco.com/t/chapter-2-custom-subscriber/123792>\
**Category:** Combine: Asynchronous Programming with Swift\
**Created:** [October 30, 2020, 10:32am UTC](https://forums.kodeco.com/t/chapter-2-custom-subscriber/123792 "2020-10-30T10:32:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![novinfard](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/novinfard/32/92983_2.png) [@novinfard](https://forums.kodeco.com/u/novinfard)\
**Post date:** [October 30, 2020, 10:32am UTC](https://forums.kodeco.com/t/chapter-2-custom-subscriber/123792/1 "2020-10-30T10:32:31Z")

</div>

I don’t understand why the output of the following code:

```auto
example(of: "Custom Subscriber") {
    let publisher = (1...10).publisher

    final class IntSubscriber: Subscriber {
        typealias Input = Int
        typealias Failure = Never

        func receive(subscription: Subscription) {
            subscription.request(.max(3))
        }

        func receive(_ input: Int) -> Subscribers.Demand {
            print("Received value", input)
            return .max(1)
        }

        func receive(completion: Subscribers.Completion<Never>) {
            print("Received completion", completion)
        }
    }

    let subscriber = IntSubscriber()
    publisher.subscribe(subscriber)
}

```

is the following code:

```auto
**——— Example of: Custom Subscriber ———**

**Received value 1**

**Received value 2**

**Received value 3**

**Received value 4**

**Received value 5**

**Received value 6**

**Received value 7**

**Received value 8**

**Received value 9**

**Received value 10**

**Received completion finished**

```

We initially requested for 3 items, and each time we increased the request by one, so totally we should receive 6 items and shouldn’t have reached the completion.
