Skip to content
Chany edited this page Jun 18, 2018 · 5 revisions
지금 구조에서는
controller 의 이런 메서드들이 어디서 어떻게 불리는지 알수가 없어서 약간 답답하네요.

그리고 메서드 이름이 '메시지'와 일치시킨 건 나름대로의 아이디어로 보여요.
다만 이름과 메시지명을 일치시켜야 해서 이름이 변경되면 양쪽을 모두 수정해야 하는 이슈가 있을 거 같네요.
물론 이렇게 구현해도 큰 문제가 있는 건 아니고요.

피드 내 생각

  1. ㅇㅇ bind되거나 observable로 한 부분은 어떻게 얽혀있는지가 보인다. 그런데 지금 코드에서는 emit을 하는 부분이 다 model이랑 view에서만 나타나져 있다. 컨트롤러에서 파악하기 어려운 문제가 있다

문제는 인식했는데 어떻게 해결할 수 있을까?.? ...

observable notify와 비슷 emit에서 eventName과 data을 보내주는 것과 짜본 observable 패턴에서도 data, type type으로 method를 구분시키는 것 많이 흡사 함

  initRender(){
    this.vendingMachineViewInitRender()
    this.walletViewInitRender()
  }
  vendingMachineViewInitRender(){
    const snackList = this.vendingMachine.getSnackList()
    this.vendingMachineView.initRender(snackList)    
  }
  walletViewInitRender(){
    const myMoney  = this.wallet.getMyMoney();
    const toatlMoney = this.wallet.getTotalMoney()
    this.walletView.initRender(myMoney, toatlMoney);
  }

능동적으로 렌더링을 한다. data를 직접 넣어준다. 이게 맞는 건지 ?

document.addEventListener("DOMContentLoaded", (e)=> {
  console.log("DOM fully loaded and parsed");
  // rendering 
  walletView.initRender(myMoney,wallet.getTotalMoney());
  vendingMachineView.initRender(snackList);
});