Core Concepts of Combine
Publisher, Subscriber, Operators and Subjects
No matter your coding background, you will need to get to grips with some of the core concepts of Combine
, what it does and how to perform some programming tasks in the same.
This article is here to help you!
What is Combine?
Combine
is about what to do with values over time, including how they can fail.
This means that Combine
uses many of the functional reactive concepts that are used by RxSwift
(if you are familiar with that), but is Apple’s implementation is baked-in to the iOS SDK meaning it has the advantages of Swift, being type-safe and usable with any asynchronous API
.
In addition to functional programming primitives like map
, filter
, and reduce
you can split and merge streams of data.
These steams are important as we can visualise events (keyboard taps, touches etc.) as such a stream that can be observed. The observer pattern watches an object over time, notifying changes — and applied over time this would produce a stream of objects.