[iOS][Team10][Dumba, Min] MVVM 패턴적용, DetailView, CoreData #60
[iOS][Team10][Dumba, Min] MVVM 패턴적용, DetailView, CoreData #60ghis22130 wants to merge 18 commits intocodesquad-members-2021:team10from
Conversation
의존성을 주입해줄 수 있도록 MVVM Pattern 변경 & Dictionary Type이었던 menu property 를 2차원 Array Type으로 변경
반찬디테일 레파지토리, 유즈케이스, 뷰모델, 뷰컨트롤러를 만들어 Flow 연결
BanchanDetailViewModel의 detail을 ViewController와 binding 해주었습니다. BanchanDetailAPIEndPoint를 생성하여 상세 반찬을 불러올 수 있게 해주었습니다
반찬상세페이지 및 주문하기 버튼 구현
Feature mod mvvm
CoreData 관련 CoreDataManager, Moddel, Repository를 생성하였고 DTO, Entity의 자료 변환도 구성하였습니다
BanchanListStorage과 관련된 의존성을 주입하였습니다.
주문하기 버튼 누르면 주문완료 & 재고부족 Alert 창 띄우도록 구현 및 오토레이아웃 버그 수정
…dish into feature/CoreData2
재고가 없는 상품일 경우 주문하기 버튼이 일시 품절로 바뀌며 버튼이 비활성화 되어 주문이 불가하도록 설정하였습니다
Feature/core data2
napster-x-90
left a comment
There was a problem hiding this comment.
Coordinator가 생겼네요! 😙 MVVM의 단점은 무엇일까요? 왜 Coordinator가 필요할까요?
꼭 알고 쓰셔야합니다.
이번주도 수고 많으셨습니다!!
|
|
||
| import UIKit | ||
|
|
||
| class AppFlowCoordinator { |
There was a problem hiding this comment.
Coordinator 를 도입하셨군요 :) 좋습니다.
혹시 그럼 Coordinator 는 왜 필요할까요?
| import UIKit | ||
|
|
||
| class AppFlowCoordinator { | ||
| private var navigationController: UINavigationController |
There was a problem hiding this comment.
navigationController도 let으로 해도 될 것 같습니다.
| } | ||
|
|
||
| // MARK: - Persistent Storages | ||
| private func makeBanchanListStroage() -> CoreDataBanchanListStorage { |
There was a problem hiding this comment.
stroage -> storage 오타가 있는 것 같네요 :)
|
|
||
| // MARK: - ViewModel | ||
| private func makeBanchanDetailViewModel(hash: Int, action: BanchanDetailViewModelAction) -> BanchanDetailViewModel { | ||
| return BanchanDetailViewModel(hash: hash, fetchBanchanDetailUseCase: makeFetchBanchanDetailUseCase(), action: action) |
There was a problem hiding this comment.
hash 라는 이름이 처음 보는 저에겐 크게 와닿진 않네요.
로직을 파악하고난뒤에 hash가 어떨때 필요한 인자인지 알게 되었습니다.
읽기 좋은 코드는 다른곳을 찾아보지 않고 바로 봤을때 인지 할 수 있는 코드입니다.
매개변수명을 바꿔보는건 어떨까요? 🤔
| } | ||
| } | ||
| } catch { | ||
| print("error in sectionEntity") |
There was a problem hiding this comment.
PR코드에서는 print는 없어야합니다. :) 이놈의 error처리가 문제내요 항상. 꼭 고민해보세요. 어떻게 해야할까요?
| } | ||
| try context.save() | ||
| } catch { | ||
| fatalError() |
There was a problem hiding this comment.
여기서는 fatalError가 있네요. 이런식의 에러는 아주 좋지 않습니다. 앱이 죽어버리거든요.
| let container = NSPersistentContainer(name: "CoreDataStorage") | ||
| container.loadPersistentStores { _, error in | ||
| if let error = error as NSError? { | ||
| // TODO: - Log to Crashlytics |
There was a problem hiding this comment.
Crashlytics에도 로그를 올리게 구현되었나요?
동일합니다. persistentContainer에 load를 실패하면 어떻게 해야할까요?
| @IBOutlet weak var totalPriceLabel: UILabel! | ||
|
|
||
| @IBOutlet weak var orderButton: UIButton! | ||
| private var quantity: Int = 1 |
| viewModel.didTappedOrderButton(quantity: quantity) { result, error in | ||
| var alert: UIAlertController! | ||
|
|
||
| switch result { |
There was a problem hiding this comment.
응답에 대한 결과처리를 View에서 하는 역할은 아닌 것 같습니다.
QCombine을 사용하는 Publisher property에 private (set) 접근 제한자를 지정해 두었는데 이게 적합한 접근인지 고민입니다. A해당 속성에 값을 읽어오려면 적합한 접근인게 맞습니다. :) |
리드미에 실행화면에대한 설명과 gif 파일을 업데이트하였습니다
작업 내용
고민 거리 & 개선 방향