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

[Fix] #52 Cart, OrderDetail 네트워킹 의존성주입 #53

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

kimscastle
Copy link
Contributor

1. 의존성주입을 위한 추상화

CartManager

  1. DIP를 위해 추상화된 객체를 생성
protocol CartManagerNetwork: AnyObject {
    func fetchCartDTO(completion: @escaping (CartModelDTO) -> Void)
    func deleteCartMenu(menuID: Int)
    func orderComplete(cartID: Int, completion: @escaping (Bool)->Void)
}
  1. 해당프로토콜을 Manger객체가 채택하고
final class CartManager: CartManagerNetwork {}

3.해당 프토토콜을 따르는 객체를 외부에서 주입시켜줌(생성자를만들고 외부에서 주입)

init(cartManager: CartManagerNetwork) {
     self.cartManager = cartManager
    super.init(nibName: nil, bundle: nil)
}
let cartViewController = CartViewController(cartManager: CartManager.shared)
self.navigationController?.pushViewController(cartViewController, animated: true)

OrderDetailManager

  1. DIP를 위한 추상화된 객체를 생성
  • 지금 서버를 닫아놓은 상태이고 이쪽 OrderViewController네트워킹이 연결이 안되있던 상황이라 네트워크 코드만 추상화를 통한 분리작업만 수행
protocol OrderDetailNetwork: AnyObject {
    func appendMenuInCart(cartID: Int, storeID: Int, menuName: String, menuImage: String, totalPrice: Int, options: String, totalCount: Int, completion: @escaping (Bool) -> Void)
}

protocol에는 parameter의 기본값 설정이 안된다는사실을 알게됨

  1. 해당프로토콜을 Manger객체가 채택
final class OrderDetailManager: OrderDetailNetwork {}

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

Successfully merging this pull request may close these issues.

1 participant