Jump to ratings and reviews
Rate this book

Asynchronous Programming with SwiftUI and Combine: Functional Programming to Build UIs on Apple Platforms

Rate this book
Develop UI-heavy applications more easily, faster, and error-free. Based on several enhancements to the Swift language, SwiftUI takes a declarative approach to building UIs. Instead of imperatively coding the UI, this book will show you how to describe how you want your UI to look.

SwiftUI treats the UI as a function of its state, thereby making managing your app’s state a lot easier. Change the underlying data model to redraw all parts of the UI that are connected to that particular slice of data. Likewise, easily update the underlying data model from the UI elements your data model is connected to. Combine is Apple’s Functional Reactive Programming framework. It complements SwiftUI and other frameworks, such as the networking APIs, in a natural way. Using Combine, you can subscribe to events and describe data processing in a way that is free of side effects. This allows for an easier implementation of event-driven applications.

Using SwiftUI and Combine build more error-free apps in a shorter amount of time, targeting all of Apple’s platforms (iOS, iPadOS, watchOS, macOS, tvOS) with little to no overhead.

By the end of the book you will have a solid understanding for architecting and implementing UI-heavy apps in a declarative and functional reactive way using SwiftUI, Combine, and async/await.

You will:
* Build simple and gradually more complex UIs in SwiftUI
* Understand SwiftUI’s state management system
* Work with Combine and Swift’s new async/await APIs to access the network and access other asynchronous APIs
* Architect and structure modern applications on Apple platforms using SwiftUI, Combine, and async/await

434 pages, Paperback

Published January 14, 2023

10 people are currently reading
12 people want to read

About the author

Peter Friese

1 book18 followers
I'm a software engineer, author, speaker, and musician with a passion for helping developers build great apps. Currently, I work as a Developer Relations Engineer / Developer Advocate on the Firebase team at Google, where I focus on helping developers build better apps using Firebase on iOS and other Apple platforms.

Ratings & Reviews

What do you think?
Rate this book

Friends & Following

Create a free account to discover what your friends think of this book!

Community Reviews

5 stars
4 (40%)
4 stars
6 (60%)
3 stars
0 (0%)
2 stars
0 (0%)
1 star
0 (0%)
Displaying 1 - 3 of 3 reviews
1 review
February 11, 2023
The TL;DR

The topic of Reactive Programming is incredibly exciting, offering the potential to enhance app development. The book, "Asynchronous Programming with SwiftUI and Combine," has appeals to both experienced developers and beginners alike. The author provides a thorough context for SwiftUI, Reactive Programming, and Swift Concurrency, making it an accessible and informative read. The accompanying Github repository provides code samples for every chapter, allowing you to dive into the practical application of the concepts covered in the book.

Reactive Programming
I am a big fan of Reactive Programming and I have been a happy user of RxSwift for the past 7 years. RxSwift is an Open Source project that predates Combine and shares many of the same properties. I think that it's also fair to say that RxSwift and the Reactive Extensions programming pattern invented by Eric Meijer must both have influenced and inspired the design of Combine.

One of the bigger issues of Reactive Programming is that it requires a different mindset from imperative programming. This might cause some people to reject the concept, since at first glance it might look unfamiliar and a bit daunting. The ease of onboarding new colleagues to a 'reactive' code base was one of the biggest considerations when making the decision of using RxSwift throughout our code base at Ka-ching.

That's why I was thrilled to learn about Peter Friese's book that explains Reactive Programming (in the context of Combine) and its connection to SwiftUI and Swift Concurrency.

Peter Friese is a Senior Developer Advocate at the Google Firebase team and an experienced and enthusiastic software engineer.

About the book
Part 1 of the book provides a thorough explanation of SwiftUI, from its introduction and theory to practical examples of views, state management, and complex interactions. It's a great resource for those new to SwiftUI and a useful refresher for those already familiar with it.

Part 2 introduces Reactive Programming through Combine and its powerful built-in functionality such as debouncing, automatic cancellation of asynchronous tasks, retrying, deduplication, and more. It's a great introduction for those new to Reactive Programming and a helpful reminder for those who already know about it.

Part 3 takes a look at Swift Concurrency and how this ties into the story of Combine and SwiftUI. It contains examples of code where an async/await approach is the simpler choice, but also use cases where the powerful operators of Combine provide functionality that would be hard to reproduce in a pure async/await world.

Why should you learn about Reactive Programming?
Reactive Programming transforms the way you model your domain by treating it as signals of values that change over time. Adopting this mindset leads to apps that are more responsive and capable of real-time updates in all aspects, from model entities to configuration and theming.

At my job at Ka-ching, we have developed a Point-of-Sale app for iPad, iPhone, and macOS. The back-end is built on real-time updating databases (Firebase Realtime Database and Firestore), which align perfectly with the concept of Reactive Programming.

All model entities in the app, such as products, discount campaigns, currency definitions, exchange rates, and more, are updated in real-time. The same is true for configuration and theming. Customer-facing displays immediately reflect real-time updates of the contents of the "basket" that is being assembled in the POS app.

When you adopt a mindset of modeling your domain as signals of values that change over time, you start to carefully consider the few places where data needs to be locally "constant." For example, in Ka-ching POS, only the shop's id is constant when selecting a shop to log into, but all properties of the shop, such as the market it belongs to, the default currency it uses, and the entire definition of products available in a given market, can change. The same is true when viewing product details, where only the product id is constant, but all other properties of the product can change.

In my opinion, this leads to a great user experience, and it is satisfying to see user reactions to the immediate feedback they receive in the app, whether they are changing properties of a product in the back end, configuration, or theming.

Learning the concepts of Reactive Programming enables you to build this type of app experience, and "Asynchronous Programming with SwiftUI and Combine" is an excellent starting point for learning.
Profile Image for Yigit Yilmaz.
68 reviews10 followers
March 30, 2023
This is a quite nice book which focuses most modern techniques on iOS development such Combine, Async programming and SwiftUI. Tons of practical samples make understanding the concepts intuitively.

I also liked the Peter's style of approaching problems. He always mentioned the trade-offs of the topics and keeping a skeptical attitude rather than dictating like it is an only true way.

I broke 1 start just because of the design of the book. I had a hard copy and some pieces, especially the images from Xcode, difficult to read. I think that needs to be reviewed and should be improved. It is probably an issue caused by the publisher.

In recap, get the e-book and start to read.
Profile Image for Noura Rizk.
460 reviews118 followers
June 7, 2023
It's been a while since I finished this book, but from what I remember Peter was good at simplifying not-so-simple topics with great examples, and that was what I was looking for in a technical book tbh. Also, I think it's one of these books you gonna re-read again.
Displaying 1 - 3 of 3 reviews

Can't find what you're looking for?

Get help and learn more about the design.