Sneak Peek: First Chapter From New SwiftUI, Combine, and Catalyst Books!
An exclusive sneak peek of our three brand new upcoming iOS books on SwiftUI, Combine & Catalyst is available now! By Tiffani Randolph.
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress, bookmark, personalise your learner profile and more!
Create accountAlready a member of Kodeco? Sign in
Contents
Sneak Peek: First Chapter From New SwiftUI, Combine, and Catalyst Books!
25 mins
2) Combine: Asynchronous Programming with Swift
Third-party reactive frameworks including RxSwift and ReactiveSwift have been revolutionizing how apps are built. With Apple’s introduction of the Combine framework, it is now possible to apply these same declarative and reactive programming techniques without third-party library dependencies — it’s a real game-changer!
This book is for people who have experience with Swift. Knowledge of other reactive programming libraries may be useful but is not necessary, because the book will cover everything from the ground up.
In today’s sneak peek, we are releasing Chapter 2 of the book, which shows you how to work with publishers and subscribers, and manage the subscriptions that are created between the two of them.
Again this is just a preview of what’s coming soon to tide you over; the full book will have much more. Here’s the full table of contents:
- Hello Combine: A gentle introduction to what kind of problems Combine solves, a back story of the roots of reactive programming on Apple’s platforms, and a crash course into the basic moving pieces of the framework.
- Publishers & Subscribers: The essence of Combine is that publishers send values to subscribers. In this chapter you’ll learn all about what that means and how to work with publishers and subscribers, and manage the subscriptions that are created between the two of them.
- Transforming Operators: Before a subscriber receives values from a publisher, you’ll often want to manipulate those values in some way. One of the most common things you’ll want to do is transform those values into some form that is ideal for use by the subscriber. By the end of this chapter you’ll be transforming all the things.
- Filtering Operators: In this chapter you’ll learn about filtering elements from Combine publishers, so you can easily control the values published by the upstream and only deal with the ones you care about.
- Combining Operators: Publishers are extremely powerful, but they’re even more powerful when composed together! This chapter will teach you about Combine’s combining operators which let you take multiple streams and create meaningful logical relationships between them.
- Time-based Operators: A large part of asynchronous programming relating to processing values over time, this chapter goes into the details of performing complex time-based tasks that would be hard to do without Combine.
- Sequence Operators: When you think about it, Publishers are merely sequences. As such, there are many useful operators that let you target specific elements, or gather information about the sequence as a whole, which you’ll learn about in this chapter.
- In Practice: Building a Collage app: It’s time to try your new Combine skills in a real project and learn how to make Foundation and UIKit play along with your reactive code.
- Combine for Networking: This chapter teaches you how to seamlessly integrate network requests in Combine publisher chains and make your networking easier and more resilient.
- Debugging Combine: Debugging asynchronous code being notoriously harder linear code, Combine helps with a few tools that will greatly help you improve your understanding of the processes at play.
- Combine Timers: A niche part of your code, timers are always useful to have around and easy to create in Combine, as you’ll learn in this chapter.
- Key-Value Observing: This chapter shows you how Key-Value Observing, which was historically the best way to get notified when a value changed, now integrates nicely with Combine publishers.
- Resources in Combine: Precisely controlling resource usage is a touchy subject, but this chapter will shed light on sharing operators which let you do just that.
- In Practice:Networking: In this chapter, you will work on a networking API that talks in real-time to the Hacker News servers and along the way exercise using multiple operators and publishers in Foundation.
- In Practice: SwiftUI with Combine: SwiftUI is the new user interface paradigm from Apple and it’s designed for an interplay with Combine on a whole new level. In this chapter, you are going to work through a Combine based SwiftUI project.
- Error Handling in Practice: This chapter will teach about Combine’s powerful typed error system, and how you can leverage it to handle errors in your app, and within Combine publishers.
- Combine Schedulers: In this chapter, you’ll learn what Schedulers are, how they relate to RunLoops, Dispatch queues and Threads and how Combine extends Foundation to integrate with them.
- Custom Publishers & Handling Backpressure: Creating your own publishers and operators is an advanced topic you’ll learn to master in this chapter, while also learning about and experimenting with backpressure management.
- Testing Combine Code: This chapter will introduce you to unit testing techniques for use with Combine code. You’ll go from testing basics in a playground to applying what you’ve learned in adding tests to an existing iOS app project.
- In Practice: A Complete Combine App: You’ve gained valuable skills throughout this book, and in the last section you picked up some advanced Combine know-how too. In this final chapter, the pièce de résistance, you’ll build a complete app that applies what you’ve learned—but the learning is not done yet! Core Data in Combine anyone?
Section I: Introduction to Combine
Section II: Operators
Section III: Combine in Practice
Section IV: Advanced Combine
Section V: Building a Complete App
About the Combine Authors
Marin Todorov is an author of this book. Marin is one of the founding members of the raywenderlich.com team and has worked on eight of the team’s books. He’s an independent contractor and has worked for clients like Roche, Realm, and others. Besides crafting code, Marin also enjoys blogging, teaching and speaking at conferences. He happily open-sources code. You can find out more about Marin at www.underplot.com.
Shai Mishali is an author and the final pass editor on this book. He’s the iOS Tech Lead for Gett, the global on-demand mobility company; as well as an international speaker, and a highly active open-source contributor and maintainer on several high-profile projects – namely, the RxSwift Community and RxSwift projects, but also releases many open-source endeavors around Combine such as CombineCocoa, RxCombine and more. As an avid enthusiast of hackathons, Shai took 1st place at BattleHack Tel-Aviv 2014, BattleHack World Finals San Jose 2014, and Ford’s Developer Challenge Tel-Aviv 2015. You can find him on GitHub and Twitter @freak4pc.
Scott Gardner is an author and the technical editor for this book. Combined, he’s authored over a dozen books, video courses, tutorials, and articles on Swift and iOS app development — with a focus on reactive programming. He’s also presented at numerous conferences. Additionally, Scott teaches app development and is an Apple Certified Trainer for Swift and iOS. Scott has been developing iOS apps since 2010, ranging from personal apps that have won awards to working on enterprise teams developing apps that serve millions of users. Say hello to Scott on Twitter @scotteg or connect with him on LinkedIn at scotteg.com.
Florent Pillet is an author of this book. He has been developing for mobile platforms since the last century and moved to iOS on day 1. He adopted reactive programming before Swift was announced, using it in production since 2015. A freelance developer, Florent also uses reactive programming on the server side as well as on Android and likes working on tools for developers like the popular NSLogger when he’s not contracting, training or reviewing code for clients worldwide. Say hello to Florent on Twitter and GitHub at @fpillet.