Combine Essentials

9 Episodes

Episode 3

Merging Publishers With Combine's Merge Operator

This episode of Combine Essentials zooms in on Combine's merge operator. As the name suggests, the merge operator merges two or more upstream publishers into a single publisher. Even though the merge operator isn't difficult to use, there are a few pitfalls to watch out for.

Episode 4

When to Use Combine's TryMap Instead of Map

In an earlier installment of Combine Essentials, you learned about Combine's map operator, one of the most commonly used operators. The map operator has one important limitation. The closure you pass to the map operator can't be throwing. Don't worry, though. Combine's tryMap operator addresses this shortcoming.

Episode 5

Changing a Publisher's Failure Type with SetFailureType

Every Combine publisher defines two associated types, the Output type defines the type of elements the publisher can emit and the Failure type defines the type of errors the publisher can emit. The fact that a publisher is required to define an Output type and a Failure type is convenient, but it can sometimes be inconvenient.

Episode 6

Observing a Text Field with Combine

What I love most about RxSwift is RxCocoa. RxCocoa defines a wide range of integrations with UIKit and AppKit. It is surprising that Apple's Combine framework lacks these integrations. The good news is that most of the integrations RxCocoa defines are easy to implement using Combine. In this episode, I show you how to observe the value of a UITextField instance using the Combine framework.

Episode 7

Combining Publishers with Combine's Zip Operator

The Combine framework defines a number of operators to combine two or more publishers into a single publisher. Each of these operators serves a specific purpose. In this episode, I show you how to use the zip operator to combine publishers.

Episode 8

How to Use Combine's ReplaceNil Operator

Earlier in this series, I explained how you can use Combine's compactMap operator to filter out nil elements emitted by a publisher. While this is a common use case, there are scenarios in which you don't want to filter out nil elements. Instead you want to replace the nil elements with a default or fallback value. In this episode of Combine Essentials, you learn about the replaceNil operator to do just that. Note that I don't recommend developers to use the replaceNil operator due to its unintuitive behavior. I explain this in more detail in this episode.

Episode 9

How to Use Combine's Scan and TryScan Operators

A publisher is nothing more than a sequence of elements over time. Your application typically performs an action when a publisher emits an element. In some scenarios, the action you take requires the elements the publisher emitted up until that point. That is where the scan and tryScan operators come in useful. This may sound confusing so let's take a look at an example.