I am actually following the Combine book, and it’s very interesting and detailed.
However there is a weird behavior that is differing from the one explained in the book.
If I use the store(in:) function to store a subscription inside the subscriptions Set, the book says that at the end of the playground, since subscriptions is deallocated, automatically all contained subscriptions will be cancelled.
To actually check this, the book suggests you to add the print() operatore before the sink.
And the print() works indeed fine, showing all the “received” messages that the subscribers receive on their subscriptions.
But on the book is also said that on the termination of the playground, since subscriptions is deallocated, the “received cancel” should be print by all the subscriptions contained in the set, if they where not completed.
However this does not actually happen, and I even tested it by using the “final” playground provided in chapter.
If instead I force a removeAll() on the subscriptions Set, it does actually work, and the “received cancel” is printed.
Is this a problem of playground? Or are actually the subscriptions cancelled, but the receive is not printed for this event?