You can also read this article in my Xcoding With Alfian blog website using the link below.
Fetching Remote Async API with Apple Combine Framework | Xcoding with Alfian | Swift, iOS, Flutter…
Combine is a framework that has just been recently released for all Apple platforms and it is included in Xcode 11. By…
Combine is a framework that has just been recently released for all Apple platforms and it is included in Xcode 11. By using combine, it’s easier to process sequence of value over time whenever it is updated. It also helps us to simplify asynchronous code by not using delegation and avoiding complex nested callbacks.
There are several main components of Combine:
- Publisher. It’s a protocol that provides interface to publish value to the subscribers. Sometimes, it’s also referred as the upstream source. It provides generic for the
Failureerror type. A publisher that never publish an error uses
- Subscriber. It’s a protocol that provides for interface to subscribe value from publisher. It is the downstream destination in the sequence chain. It provides generic for
- Subject. It’s a protocol that provides interface to the client to both publisher and subscriber.
- Operator. By using operator, we can create a new publisher from a publisher by
filter, and even
combinevalues from the previous or multiple upstream publishers.
Apple also provides several built in Combine functionality inside the Foundation framework such as Publishers for
KVO based property observing. Those built in interoperability really helps for us to integrate the framework into our current project.
To learn more about the basic of Combine such as, you can visit Ray Wenderlich site below. It’s a great introduction to learn about the basic of Combine.