-
Notifications
You must be signed in to change notification settings - Fork 1
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
[Refactor] Observable 적용 + 피드백 반영 #33
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM ~
extension LoginView { | ||
|
||
func getUsername() -> String? { | ||
return usernameTextField.text | ||
} | ||
|
||
func bind(username: String, password: String, autoLogin: Bool) { | ||
usernameTextField.text = username | ||
passwordTextField.text = password | ||
updateAutoLoginCheckButton(autoLogin: autoLogin) | ||
func getPassword() -> String? { | ||
return passwordTextField.text | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이렇게 처리해줘도 좋지만, 굳이 이렇게 처리할 필요는 없어요 ~!
저는 개인적으로 뷰컨에서 loginView.passwordTextField.text 으로 불러오는 방식을 조금 더 선호합니다! (그러면 뷰에서 passwordTextField가 private이 아니게만 조정해주면 됩니당) 굳이 멍청해야 하는 뷰가 데이터 전달 함수를 가지고 있을 필요가 없다구 생각해요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오호.. 이렇게 생각하는 것도 일리가 있네요..! @cirtuare
혹시 캡슐화를 강화하기 위해 loginView.usernameTextField를 private으로 제한하고
getUsername(), setUsername(text:), setUsernameDelegate(_:) 메소드를 만드는 것에 대해서는 어떻게 생각하시나요?
// LoginView
func getUsername() -> String? {
return usernameTextField.text
}
func setUsername(text: String?) {
usernameTextField.text = text
}
func setUsernameDelegate(_ delegate: UITextFieldDelegate) {
usernameTextField.delegate = delegate
}
// LoginViewController
override func bind() {
loginViewModel.usernameBinding.bind { [weak self] username in
guard let self = self else { return }
loginView.setUsername(text: username)
}
...
}
private func handleLoginInfo() -> LoginInfo? {
guard let username = loginView.getUsername(),
let password = loginView.getPassword(),
...
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
사실 일회성이라면 굳이.. 싶긴 한 부분이지만, getUsername / setUsername 메소드를 쓸 일이 많으면 이렇게 짤 것 같아요 !!
또는 extension으로, textfield의 text를 get / set 하는 함수를 만들어두고 두고두고 활용하는 방식을 도입해도 될 것 같습니다. 전 뷰에 걸쳐 textfield의 text를 많이 가져오고 세팅하니까요 ~ !!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오호... 답변 감사합니다!! 도움이 됐어요😁
guard let username = loginView.getUsername(), | ||
let password = loginView.getPassword(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
전 리뷰를 적용한다면, 여기서 그냥 let password = loginView.passwordTextField.text으로 접근해주면 돼용
🔍 What is the PR?
💭 Related Issues
📝 변경 사항
🙏 To Reviewers