What Combine is for, and what has replaced most of it
Combine is Apple’s framework for values that arrive over time: a network response, a text field’s
contents, a notification, the tick of a timer. Instead of a callback per source, every source becomes
a Publisher, and publishers compose.
let cancellable = NotificationCenter.default
.publisher(for: UITextField.textDidChangeNotification)
.compactMap { ($0.object as? UITextField)?.text }
.debounce(for: .milliseconds(300), scheduler: RunLoop.main)
.removeDuplicates()
.sink { query in search(query) }
Four operators replace a debounce timer, a “did it change?” check and a delegate.
Warning
Much of what Combine was written for is now in the language. async/await covers one-shot
work better than Future, and AsyncSequence covers streams with less machinery. Reach for
Combine when you genuinely need its operator vocabulary — merging, combining latest values,
backpressure — not out of habit.
This is a template chapter. The full text is still being written.