-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Conflicts: # iOS/Features/SelectSong/Package.swift
- Loading branch information
1 parent
ca83a52
commit 2764b62
Showing
3 changed files
with
54 additions
and
15 deletions.
There are no files selected for viewing
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
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
23 changes: 23 additions & 0 deletions
23
iOS/MSUIKit/Sources/CombineCocoa/UITextField+Combine.swift
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// | ||
// UITextField+Combine.swift | ||
// MSUIKit | ||
// | ||
// Created by 이창준 on 2023.12.03. | ||
// | ||
|
||
import Combine | ||
import UIKit | ||
|
||
public extension UITextField { | ||
|
||
var textPublisher: AnyPublisher<String, Never> { | ||
let publisher = NotificationCenter.default.publisher(for: UITextField.textDidChangeNotification, | ||
object: self) | ||
|
||
return publisher | ||
.compactMap { $0.object as? UITextField } | ||
.map { $0.text ?? "" } | ||
.eraseToAnyPublisher() | ||
} | ||
|
||
} |