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

[FEAT] 상상의 닉네임 뷰 구현 및 리팩토링(?) #48

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

Zoe0929
Copy link
Member

@Zoe0929 Zoe0929 commented Jun 4, 2024

#️⃣연관된 이슈

#47

📝작업 내용 요약

우선 매우매우 많은 파일이 바뀐 점, PR 단위가 너무 커진 점 양해 부탁드립니다. 😢

닉네임 뷰

처음 닉네임을 생성하고 userId를 가지고 있어야 가능한 통신이 있어서 닉네임 생성 뷰를 만들어 두었습니다.
임시로 UserDefaults 로 관리합니다.

❗️전체 연결이 아니기 때문에 일부 로직에서 서버 통신 실패 일어나는 부분 있습니다❗️

ex. 사용자 퀴즈 풀이가 없는데 questionId 이용해서 서버 통신 -> 404 발생

💭 기술적 고민

Moya 네트워크 계층을 추상화 해보려 했는데, 뷰모델까지 콜백 지옥에 빠져서 Rx 사용 고민 중 입니다.
MVVM 으로 리팩토링 중인데 더 좋은 방법이 있다면 꼭 코드리뷰 부탁드립니다!

스크린샷 (선택)

@Zoe0929 Zoe0929 linked an issue Jun 4, 2024 that may be closed by this pull request
Copy link
Collaborator

@sozohoy sozohoy left a comment

Choose a reason for hiding this comment

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

@Zoe0929
지희야 고생했어.. 작업 진짜 빡으로 하네 너..
궁금한건 지금 코드에서 Rx를 도입하면 어떤 이점이 있을 것 같은지가 궁금해!
나는 콜백 지옥이 싫어서 async / await를 요즘 자주 쓰려고 하는 것 같아 요즘은! 코드리뷰가 도움이 될 진 모르겠지만 최대한.. 열심히 달아봤어... 고생했어!!

import Moya


final class HomeViewModel: ObservableObject {
Copy link
Collaborator

Choose a reason for hiding this comment

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

  • viewModel에서 콜백지옥이 우려된다면 Moya를 async / await 방식으로 사용해보려고 구현해보아도 괜찮을 지도..?!

func request<T: Decodable>(_ target: Target, completion: @escaping (Result<T, Error>) -> Void)
}

class NetworkService<T: TargetType>: NetworkServiceProtocol {
Copy link
Collaborator

Choose a reason for hiding this comment

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

  • 추상화 되게 깔끔하게 잘 한 것 같은데?? 나도 Rx를 많이 써보지 않아서, Rx를 사용하면 어떤 추가적인 장점이 있을 것 같아?

Comment on lines +40 to +52
networkService.getQuestionDescription(requestDTO: request) { [weak self] result in
DispatchQueue.main.async {
switch result {
case .success(let response):
let data = response.data
self?.questionTitle = data.question
self?.answerText = data.answer
self?.questionDescription = data.solution
case .failure(let error):
print(error)
}
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

  • 이런 부분이 걱정된다면, 레포지토리를 중간에 놔둬도 괜찮을 것 같아!
  • 지희가 생각하기에 이 부분에서 Rx를 사용할 경우 어떤 이점이 존재할 것 같아?

Copy link
Member Author

Choose a reason for hiding this comment

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

사실 좀 편하게 해보려고 rx 도입 생각한건데, 뭔가 다시 생각해보니까 라이브러리 도입 없이도 충분히 고칠 수 있을 것 같다!
아키텍처부터 좀 다시 고민해볼게요!!

@@ -10,21 +10,26 @@ import Foundation
extension DTO {
Copy link
Collaborator

Choose a reason for hiding this comment

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

  • 네이밍 수정 좋습니다 :)

import Moya

// MARK: Attempt
class AttemptNetworkService: NetworkService<APITarget.Attempts> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

  • 이 부분도 requestDTO를 제한하지 않고 추상화 시킬 수 있을 것 같아!!! 하지만 따로 제한해놓은 이유가 있다면 괜찮은 것 같고!!

Copy link
Member Author

Choose a reason for hiding this comment

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

음음 서비스를 이미 추상화해서 여기까지 추상화할 생각은 안해봤네
여기도 한번 다시 살펴 보겠습니다~~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEAT] 이름 입력뷰 구현
2 participants