Reactive Programming in iOS with Combine
Learn how to manage asynchronous work in iOS the reactive way: using Combine! Master the techniques and best practices to write declarative Combine code in playgrounds and complete iOS app projects. By Josh Steele.
Learning path
This is part of the Declarative Programming with Combine learning path. View path.
Who is this for?
iOS developers who have some experience or who have worked their way through the previous courses in the iOS and Swift for Beginners learning path.
No previous reactive programming experience needed — we’ve got you covered!
Covered concepts
- Reactive Programming
- Combine Basics
- Publishers
- Subscribers
- Transforming Operators: Collect, map, replaceNil and more
- Filtering Operators: filter, removeDuplicates, ignoreOutput and more
- Combining Operators: prepend, append and more
- Timing Operators
- Scheduling Operators
- Sequencing Operators
Part 1: Getting Started
Welcome to the course! Find out a bit about the history of reactive programming, and a high level overview of Combine.
Learn about Publishers and Subscribers, which are the endpoints of the Combine pipeline, and how they work with one another.
Learn about some built in operators for Subscribers as well as Subjects, which help connect the imperative and declarative world.
In this hands-on challenge, use your knowledge of publishers and subscribers to create a blackjack dealer.
Recap what you learned about publishers and subscribers, and gear up for the rest of the course.
Part 2: Transforming & Filtering Operators
Learn about what Operators are in Combine, and get an overview of which ones you’ll learn about in this part of the course.
Collect, map, replaceNil and replaceEmpty are basic operators that can be used to transform data into another form.
Learn about how the scan and flatMap operators can be used in your code to do more advanced transformations.
In this hands-on challenge use your knowledge of transforming operators to lookup a phone number in a contact book.
Basic filtering operators like filter, removeDuplicates, ignoreOutput and compactMap can be used to narrow down which values get sent downstream to subscribers.
Learn about more filtering operators: first(where:), last(where:), drop, and prefix, which give you additional ways to keep values from traveling downstream.
In this challenge, use your knowledge of filtering operators to slim down an array of numbers to a predefined set of values.
Review what you’ve learned about transforming and filtering operators.
Part 3: Combining Operators
You’ve learned about several operators already, but there’s more! In this part, you’ll learn about combining operators.
Discover the prepend family of operators, which consists of prepend(Output), prepend(Sequence), and prepend(Publisher).
Now check out the append family of operators, which consists of append(Output), append(Sequence), and append(Publisher).
In this hands-on challenge, turn your old-school 7 digit phone number into a modern day number using combining operators.
Learn how you can use operators such as switchToLatest, merge(with:), combineLatest and zip to perform more advanced combinations of data from publisher.
In this episode, see examples of switchToLatest, merge(with:), combineLatest and zip in a Swift playground.
In this hands-on challenge, build upon the last challenge to interleave multiple arrays of data together.
Let’s recap the different combining operators you learned about in this part of the course.
Part 4: Timing, Scheduling and Sequencing Operators
Learn about the final set of operators we’ll cover: timing, scheduling and sequencing operators.
The basic timing operators like delay and collect do just what they advertise - delay values from a publisher and collect a series of emitted values.
The debounce and throttle operators come in handy when collecting data such as a person typing, keeping you from checking after every keystroke.
Learn how the timeout operators can be used to cause a publisher to time out and complete, and measureInterval to measure the interval between emissions.
In this hands-on challenge, use your knowledge of timing operators to decode a message from a set of mysterious data.
Learn about the schedule and receive operators, which can be used to tell Combine which Scheduler to use when running the operations.
Sequencing operators such as max, min, count and output can give you information on the sequence of emitted values as a whole.
Challenge time! Use your knowledge of sequence operators to give a golfer a report on their golf game.
Congrats on finishing the course! Review what you’ve learned and find out where you can go to learn more about Combine.