import Foundation
import Combine
class TestVM : ObservableObject {
@Published var password : String = ""
@Published var checkPassword: String = ""
lazy var isPasswordValid : AnyPublisher<Bool, Never> = Publishers.CombineLatest($password, $checkPassword).map { (password, checkPassword) in
return true
}.eraseToAnyPublisher()
@Published var errMsg : String = ""
var subscriptions = Set<AnyCancellable>()
init(){
Publishers.CombineLatest($password, $checkPassword).map({ (password, checkPassword) in
if password == checkPassword {
return "일치합니다"
} else {
return "일치하지 않습니다"
}
}) // String
.eraseToAnyPublisher()
.assign(to: errMsg, on: self)
.store(in: &subscriptions)
}
}
Last active
December 12, 2022 12:20
-
-
Save TuenTuenna/7f4681ad61f1fc943cf49ec940eb04de to your computer and use it in GitHub Desktop.
password check
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment