Errata for Combine: Asynchronous Programming with Swift 1st Edition

Good feedback, but I think it might be a misunderstanding

receiveCancel doesn’t mean the alert was cancelled, it means the subscription was cancelled. Consider the following scenario:

  1. Alert shows up
  2. Someone actively cancels the subscription (subscription.cancel or deallocating the owner)
  3. Alert is still visible because you didn’t do “cleanup”

If you do this sort of cleanup in the receiveCancel block, you won’t deal with this issue.,

Thanks again!

In Chapter 15’s sample code for HNReader, the timer does not fire when the VStack is after the ForEach loop:
ForEach(self.model.stories) { story in
VStack(alignment: .leading, spacing: 10) { …

However, when I switch those lines, the timer will fire normally:
VStack(alignment: .leading, spacing: 10) {
ForEach(self.model.stories) { story in

i.e. ForEach has to be inside the VStack for the timer to fire. I ran the sample code under Xcode 11.4.1

3 Likes

Hi @denisblondeau, thanks for reporting. We’re tracking this issue already, the behavior in SwiftUI has changed slightly since publishing the latest update of the book - we’ll fix it in the edition :+1:t3:

Ok - thank you for your reply ! :+1:

Nice! I spent over an hour on this yesterday trying to debug and track it down. Thanks for the post.

Yep - took me about that long to figure that one out ! This Combine book is really great - learned a lot !

I put all of my time into the TimeBadge and PostedBy helpers. I tried to make them observable and it didn’t work. Then I did a PRINT on the timer and noticed it canceled on the very next event.

Good catch!

2 Likes

Please check out the updated version of the book when you get a chance:

https://www.raywenderlich.com/books/combine-asynchronous-programming-with-swift/v2.0

I hope it helps!