Exploring Networking and Combine
Networking is a great place to start if you haven’t worked with Combine. Combine is a framework that declaratively handles a stream of values over time while supporting asynchronous operations.
Based on that description, it looks like Combine was made for networking operations!
In this chapter, we are not going to discuss what Combine is – for that, we’ve got Chapter 11. However, we are going to discuss it now because Combine is a great way to solve many networking operations problems.
Since Combine is built upon publishers and operators, it is simple to create new publishers that stream data from the network.
Let’s try to request the list of contacts from previous examples using a Combine stream. We’ll start with creating a publisher that performs data fetching from the network and publish a list of contacts:
class ContactRequest { func fetchData() -> AnyPublisher<[Contact...