UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Is Combine only for SwiftUI developers?

Recorded – watch the full episode on YouTube.

Do you think Combine is for SwiftUI people or not for SwiftUI people and mainly a UIKit or AppKit? Who should be using it now?

Daniel Steinberg: It's a really interesting question. Certainly from the requirements of the system, any system that can run Combine can run SwiftUI, but I know engineers that are comfortable with UIKit, and they don't want to go to SwiftUI yet. They've been using React or something, so they do want to move over to Combine. When we were allowed to travel, I taught Combine five times in the last couple months and I began the day with Combine for UIKit. Because I wanted to decouple it for them. I wanted to show them you didn't need one for the other.

And UIKit, they've done some really nice work so that UIKit works very nicely with Combine. I don't know what we're going to see from Apple. Apple tends not to document existing things, they document the future and so I would bet most of the Combine docs that we see will be SwiftUI. It’s maybe mean of me to say, but we're nine months in and we still haven't seen docs for Combine and not much for SwiftUI. It's a real shame. I mean really, there should be no room for us to make money.

“I taught Combine five times in the last couple months and I began the day with Combine for UIKit. Because I wanted to decouple it for them. I wanted to show them you didn't need one for the other.”

Paul Hudson: You're absolutely right. It does seem geared more towards the kits more than SwiftUI though, in terms of interacting with controls. For example, it’s fairly easy to do using KVO in UIKit, but trickier in SwiftUI. Do you think that's going to improve or change over time, perhaps?

Daniel Steinberg: I don't know that it is harder in SwiftUI. If you use this view model, this guy that's the gooey part in the middle, that gooey part in the middle can subscribe. So the other thing of Combine, let me back up a second and say, one of the issues with WWDC is that they've got to present things. Their presentations are masterful. I've gone back over their Combine ones a couple times and there is so much in them. They're really good. But they're generally presenting everything on a single slide, which means they're not breaking up the Combine pipeline into different pieces.

“I think it is very SwiftUI friendly. You just need that extra transformation right before it.”

And so with SwiftUI, my network layer or something is publishing something, right before SwiftUI, and the view model is basically publishing it back out using an @Published. And so SwiftUI is just listening, but it's the guy right before it that's transforming it into the form it needs. So I think it is very SwiftUI friendly. You just need that extra transformation right before it.

This transcript was recorded as part of Swiftly Speaking. You can watch the full original episode on YouTube, or subscribe to the audio version on Apple Podcasts.

Listen on Apple Podcasts

TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and free gifts!

Find out more

Sponsor Hacking with Swift and reach the world's largest Swift community!

BUY OUR BOOKS
Buy Pro Swift Buy Pro SwiftUI Buy Swift Design Patterns Buy Testing Swift Buy Hacking with iOS Buy Swift Coding Challenges Buy Swift on Sundays Volume One Buy Server-Side Swift Buy Advanced iOS Volume One Buy Advanced iOS Volume Two Buy Advanced iOS Volume Three Buy Hacking with watchOS Buy Hacking with tvOS Buy Hacking with macOS Buy Dive Into SpriteKit Buy Swift in Sixty Seconds Buy Objective-C for Swift Developers Buy Beyond Code

Was this page useful? Let us know!

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.