Understanding the Combine framework
Apple released the Combine framework in 2019, and they defined it as a framework that provides a declarative Swift API for processing values over time. There are publishers, which produce those values, and subscribers, which consume them. These values that change over time may represent different asynchronous events.
Let's see an overview of the Publisher and Subscriber protocol definitions to understand their key concepts in the following sections.
Understanding Publisher
As mentioned before, publishers are used in Combine to produce values over time. Let's dig into the Swift protocol that defines them to understand the key concepts. The Publisher
definition in Swift looks as follows:
public protocol Publisher { //1 associatedtype Output //2 associatedtype Failure : Error //3 public...