# Chapter 8: Collage - Clear Function fails

**URL:** <https://forums.kodeco.com/t/chapter-8-collage-clear-function-fails/84599>\
**Category:** Combine: Asynchronous Programming with Swift\
**Created:** [October 10, 2019, 7:22pm UTC](https://forums.kodeco.com/t/chapter-8-collage-clear-function-fails/84599 "2019-10-10T19:22:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![robsnow68](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/robsnow68/32/105896_2.png) [@robsnow68](https://forums.kodeco.com/u/robsnow68)\
**Post date:** [October 10, 2019, 7:22pm UTC](https://forums.kodeco.com/t/chapter-8-collage-clear-function-fails/84599/1 "2019-10-10T19:22:13Z")

</div>

Loving the early release previews. In the Collage project, the clear function:  
**@IBAction**  **func** actionClear() {  
images.send([])  
}

…works perfectly when adding the single image.  
However, as soon as you subscribe to the PhotoViewController, it no longer works  
As far as i can tell emptying the array on images should work

---

<div class="post-metadata">

**Author:** ![alanquatermain](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/alanquatermain/32/100712_2.png) [@alanquatermain](https://forums.kodeco.com/u/alanquatermain)\
**Post date:** [October 19, 2019, 4:41am UTC](https://forums.kodeco.com/t/chapter-8-collage-clear-function-fails/84599/2 "2019-10-19T04:41:21Z")

</div>

It appears to be happening due to the completion sent down the publisher chain by the photos view controller in `viewWillDisappear`. At a guess, the `images` subject is responding to that by closing itself down, and no longer accepting inputs (or no longer passing them down the chain). Removing the line that sends the completion causes the app to work as advertised.

Interestingly, the subscribers just keep piling up. I’m not clear on whether they’ve even been cancelled.

---

<div class="post-metadata">

**Author:** ![freak4pc](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/freak4pc/32/101113_2.png) [@freak4pc](https://forums.kodeco.com/u/freak4pc)\
**Post date:** [October 19, 2019, 9:31am UTC](https://forums.kodeco.com/t/chapter-8-collage-clear-function-fails/84599/3 "2019-10-19T09:31:03Z")

</div>

Hey, thanks both @robsnow68 @alanquatermain ! The reasoning, as you’ve guessed is that when using `subscribe(images)`, the completion event is also sent through the current value (images) subject.

If you replace:

```swift
.subscribe(images)

```

With:

```swift
.assign(to: \.value, on: images)

```

You should be good to go 🙂

We’ll make sure this is fixed in the final version of the book.
