Question for Combine: Asynchronous Programming with Swift

Hello
I am studying Combine with the book, and I have questions on Chapter 18.

  1. There is a description like below, and I can not understand what it means. Specifically on bold text.
  1. Use the handy AnySubscriber class which takes closures, and immediately request .unlimited values upon subscription to let the publisher run to completion.

Why does the publisher run to completion when I use .unlimited?

  1. And there is the other description like,

Note: You could initially request .max(self.capacity) and receive just that, but remember that Combine is demand-driven! If you don’t request as many values as the publisher is capable of producing, you may never get a completion event!

I’m just curios why I can’t get completion when using .max(n).
If I set .max(2), I can get completion after getting two values. Can’t I?

Thanks.

@freak4pc any suggestions?

1 Like