Errata for Combine: Asynchronous Programming with Swift 1st Edition

Will I get an email when the Combine book is published? (v1) (I have purchased)

Yup, youā€™re supposed to get an e-mail once the full release is out :slight_smile: You can also follow @rwenderlich on Twitter to get the latest news on that.

@dad great catch! Will have that fixed for the final release.

Happy for more feedback from everyone as we approach the final release of the book! :]

Hi @dad, thanks for pointing this out. I did remove this remnant when it was first reported, but Iā€™m not sure why that change didnā€™t make it into the last release. However, I just double-checked and itā€™s definitely not there in the current version, for the next release. Thanks again and I hope youā€™re enjoying the book so far!

1 Like

@freak4pc Just to let you know: I did not get an email saying that v0.3.0 was released and I would have expected to (it was at v0.2.0 when I purchased). Could have just been a crazy timing thing, but thought Iā€™d let you know.

Hey, I finished reading v0.3 and so far it is great. Congrats!

I did catch some small typos here and there, but the one I can remember is in Chapter 6 (page 147) when talking about debounce and throttle. Specifically the timing example typingHelloWorld. The last element finishes at 2.5 seconds; however 2 pages later (in the debounce printout), the code finishes at 2.7 and 3.7 (instead of 2.5 and 3.5). Also 2.1 is repeated twice (instead of being 2.0 and 2.1). The same thing happens with the throttle printout.

I know the explanation is a bit confusing, but please check the code and it should be clear. The example is great to figure out the difference between the two functions. I quite liked it! I would have loved a side-by-side comparison, though. Something similar to this:

Table

It is just a suggestion, since I found myself going back and forth through the different pages. In any case, keep up the good work.

v0.3 Chapter 2, page 54

This happens because the subject previously sent a completion event that the second subscriber did receive but the first subscriber did not because it was no longer subscribed

Looks like it should be:

This happens because the subject previously sent a completion event that the first subscriber did receive but the second subscriber did not because it was no longer subscribed

P48
You also add a subscriptions set in which youā€™ll store the subscriptions to the future in the example

This never happens

P63
Type erasure enables prevents callers from being able to access additional details of the underlying type

Type erasure prevents callers from being able to access additional details of the underlying type

Chapter 7
Starter Playground is the same as Finish Playground i.e all the code has been filled in.

Chapter 8 ā€“ project doesnā€™t work if you try and resave photos due to the cancel subscription call in viewWillDisappear. To replicate - go back to PhotosViewController a second time and try and save more photos.
( Is storing each subscriber in subscriptions not sufficient and doesnā€™t the subscriber get removed once photosViewController is dismissed and deinitialized ???)

P209
A random p is included after
Websocket tasks to connect to websockets.

Hi @dehesa,

Thanks for taking the time to write down your notes and make this very nice table. While itā€™s too late to change this edition of the book we may definitely consider something similar to highlight the differences between throttle and debounce. It is a nice visual cheat sheet that will help beginners. Congrats for coming up with this!

Regarding the timing issues, there may be some slight discrepancy (delay) due to scheduling on a queue: delivery at a precise time is not guaranteed when using DispatchQueue.asyncAfter (note the after part of the call). This is something Iā€™ll make a note about in the next edition of the book, thanks for catching it!

v0.3
P73
There is an inconsistency between the code and the shown output.
I think the following line is missing:

publisher.send(Coordinate(x: 0, y: 5))

1 Like

Thank you! Thatā€™s indeed a mistake and will be fixed on the final release.

Hi @kyrya, thanks for bringing this to our attention. I do think the wording is correct, however it definitely could be worded better. Iā€™ve changed it to:

Run the playground. The second subscriber does not receive the "How about another one?" value, because it received the completion event right before that value was sent. The first subscriber does not receive the completion event or the value, because its subscription was previously canceled.

Thanks again!

Any ideas when the next edition is coming out? Will the next one be the full release?
Thanks

Yes, the full 1.0 release is pending publication.

That is awesome!! canā€™t wait for it!! Congratulations

And itā€™s out! :tada:

https://www.raywenderlich.com/6185979-combine-asynchronous-programming-with-swift-complete-book-available

Combine version 1.0 (I think, be nice if the version # of the book was easy to find inside the book in iBooks, perhaps on the copyright page?) Chapter 8 ā€œwrapping a callback function as a futureā€ section, comment number positions for this section seem off:

ā€œ// 1
try PHPhotoLibrary.shared().performChangesAndWait {
  // 2
  let request = PHAssetChangeRequest.creationRequestForAsset(from: image)

  // 3
  guard let savedAssetID =
    request.placeholderForCreatedAsset?.localIdentifier else {
    return resolve(.failure(.couldNotSavePhoto))
  }

  // 4
  resolve(.success(savedAssetID))
}ā€

The explanation says: ā€œ1. First you create a request to store imageā€ and ā€œ2. Then you attempt to get the newly-created assetā€™s identifier via request.placeholderForCreatedAsset?.localIdentifierā€. Comment #3 position also seems a couple lines high. Comment #4 positioning is correct.

1 Like

I feel like Iā€™m going crazy, but I think the very first example of sink on page 41 is missing
center.post(name: myNotification, object: nil)
I can see it in Final.playground, but the PDF doesnā€™t seem to include it.

2 Likes

Iā€™m working through Chapter 8 Challenges.

The challenge states:

ā€œOnce youā€™re finished with your first task, create a new subscription to newPhotos which:

  1. Ignore all values and only pass a completion event. You can use ignoreOutput(), just like earlier in the chapter.

  2. Use a filter operator to pass the emitted value only in case the current count of images in images.value is equal to 6 ā€” the maximum amount of photos in a collage.

  3. Use a flatMap to display an alert letting the user know they reached the maximum photos and wait until they tap the Close button.

  4. Use a sink(receiveCompletion:receiveValue:) to pop the photos view controller out of the navigation stack.

This subscription should, when the maximum number of photos for a collage is selected, pop the photos view controller automatically and take the user back to the main view controller:ā€

Excerpt From: By Marin Todorov. ā€œCombineā€. Apple Books.

I tried playing with the end result by opening the ā€œChallengesā€ folder provided.

  1. No Alert was shown
    {
    self.alert(title: ā€œLimit reachedā€, text: ā€œTo add more than 6 photos please purchase Collage Proā€)
    }
  2. It will pop the PhotosViewController only on the 7th photo tap, even when all photos selected is landscape.

Yes, and this is NOT corrected for v1.0.1. Is anyone on the team bothering to read these errata?

I tried playing with the end result by opening the ā€œChallengesā€ folder provided.

  1. No Alert was shown
    {
    self.alert(title: ā€œLimit reachedā€, text: ā€œTo add more than 6 photos please purchase Collage Proā€)
    }
  2. It will pop the PhotosViewController only on the 7th photo tap, even when all photos selected is landscape.

Hey :slight_smile: I believe the behavior youā€™re seeing here is correct regarding the popping of the VC.

Youā€™re only allowed to have 6 images so only when trying to tap a seventh image, youā€™ll see a warning (since you already have 6).

The alert not showing was fixed in the latest version thatā€™s in the store right now. Let me know if youā€™re still having any issues! Thanks :slight_smile:

P.S. Weā€™ve modified the text around this so itā€™s a bit easier to consume. I hope thatā€™ll clarify :slight_smile: