Created
July 21, 2020 16:11
-
-
Save serhiybutz/2e9ab8690ffd8ac94f24fa8c9dacef93 to your computer and use it in GitHub Desktop.
Combine: withLatestFrom, 01
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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