In Parts 1, and 2, you’ve built a custom Publisher, and did your best to cover its rough edges with unit tests. Now it’s finally time to kick back and relax while it does its job, emitting playback progress. Or is it? Of course it will work well in most cases; but what happens if some threading issues are introduced? Let’s find out!
In Part 1 of the series, you’ve built a Publisher from scratch. One of the key parts of Combine’s event delivery is keeping up with the Subscriber’s demand. It involves some manual bookkeeping, which is known to be error-prone, so in this guide you’ll learn how to ensure that your custom Publisher is not misbehaving.
If you’re just getting started with Combine, the idea of a custom publisher can sound scary, but diving into the topic has many benefits: you’ll understand how parts of the framework work together, and will be able to create your own Combine-powered APIs.