# Return subscription on subscribe

**URL:** <https://forums.kodeco.com/t/return-subscription-on-subscribe/156767>\
**Category:** Combine: Asynchronous Programming with Swift\
**Created:** [November 11, 2021, 5:06pm UTC](https://forums.kodeco.com/t/return-subscription-on-subscribe/156767 "2021-11-11T17:06:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dwroth](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/dwroth/32/103332_2.png) [@dwroth](https://forums.kodeco.com/u/dwroth)\
**Post date:** [November 11, 2021, 5:06pm UTC](https://forums.kodeco.com/t/return-subscription-on-subscribe/156767/1 "2021-11-11T17:06:32Z")

</div>

I’m trying to figure out how Apple’s own `sink` subscriber (more specifically, the sink extension on `Publisher`) is able to subscribe and then immediately return its subscription. Combine does offer a form of the `subscribe<S>()` function, but that form is only available to Subject subclasses.

The `receive<S>(Subscriber)` protocol method of the publisher doesn’t return anything, nor does the subscriber’s `receive(subscription: Subscription)` method. Rather, the subscription is passed directly from the publisher to the subscriber. If the subscriber holds a strong reference to the subscription, there is potential for a memory leak if the subscription doesn’t complete.

The only thing I can think of that Apple might be doing for `sink` is using an intermediary object that conforms to both Subscriber and Publisher and inserts itself into the hookup flow. Does anyone know how this actually works under the hood, or how to implement something similar?
