Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

회원 가입 - 텍스트 입력에 대한 버튼의 반응형 프로그래밍 구현 #4

Merged
merged 4 commits into from
Nov 16, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions MementoMori/Scenes/UserSigninScene/UserSigninViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,14 @@ final class UserSigninViewModel: ViewModelType {
}

struct Output {
let isTextValid: BehaviorRelay<Bool>
let isTextValid: Observable<Bool>
}

private let disposeBag = DisposeBag()

func transform(input: Input) -> Output {

let isValid = BehaviorRelay(value: false)

input
let isValid = input
.text
.throttle(.seconds(1), scheduler: MainScheduler.instance)
.map { $0.contains("@") && $0.contains(".") && $0.count >= 6 && $0.count < 50 }
.bind(to: isValid)
.disposed(by: disposeBag)

return Output(isTextValid: isValid)
}
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BehaviorRelay를 이용해 다시 이를 bind 하는 것이, 단순한 텍스트 입력의 유효성 검사에서는 과분한 것 같아서 Observable로 리팩토링 하였습니다.

Expand Down