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.
SAVE 50% To celebrate WWDC23, all our books and bundles are half price, so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more.
Link copied to your pasteboard.