Skip to content

Instantly share code, notes, and snippets.

@serhiybutz
Created July 21, 2020 16:11
Show Gist options
  • Save serhiybutz/2e9ab8690ffd8ac94f24fa8c9dacef93 to your computer and use it in GitHub Desktop.
Save serhiybutz/2e9ab8690ffd8ac94f24fa8c9dacef93 to your computer and use it in GitHub Desktop.
Combine: withLatestFrom, 01
import UIKit
import Combine
extension UITextField {
var textStream: AnyPublisher<String?, Never> {
NotificationCenter.default
.publisher(
for: UITextField.textDidChangeNotification,
object: self)
.map(\.object)
.map { $0 as! UITextField }
.map(\.text)
.eraseToAnyPublisher()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment