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
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.
1 Like
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:
.subscribe(images)
With:
.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.
2 Likes