-
Notifications
You must be signed in to change notification settings - Fork 4
[Mission002] TODOS 시스템에 비동기/온오프라인을 고려하여 업데이트하기 #13
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
base: master
Are you sure you want to change the base?
Conversation
| @@ -0,0 +1,16 @@ | |||
| export const eventKeyboards = { | |||
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.
상수를 enum화해서 사용하는 게 아주 편리해보입니다!!
| @@ -0,0 +1,29 @@ | |||
| export const getTodoList = async (username) => { | |||
| return await fetch(`http://todo-api.roto.codes/${username}`) | |||
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.
'http://todo-api.roto.codes/' 는 별도의 상수로 빼서 사용해도 괜찮을 것 같아요 :)
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.
BaseURL 로 따로 뺄가 고민했었는데요.ㅜ 따로 빼도록 하겠습니다!! ㅎㅎ
mission002/YongHoonJJo/js/app.js
Outdated
| this.todoListComponent = new TodoList(todoListSelector) | ||
|
|
||
| this.$input.addEventListener('keydown', async e => { | ||
| if(e.key === 'Enter') { |
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.
Constants.js에서 만들어두신 상수를 사용하셔도 좋을 것 같아요.
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.
이전에 피드백 받은 부분 적용하고 있었는데, 완전히 안된 것 같습니다. ㅜ 적용하겠습니다!
s280493
left a comment
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.
TodoList.js 파일을 조금 전에 읽었는데, TodoList.js 파일이 또 나와서 처음엔 당황했습니다..!
보니까, mission001의 코드가 섞여 있더라구요~
다음에는 PR 날려주실 때, 이전 미션의 코드는 섞이지 않게 날려주시면 더 좋을 것 같아요 :)
| } | ||
|
|
||
| TodoList.prototype.toggleEditView = function(id) { | ||
| const $liElement = document.querySelector(`li[data-action=edit-${id}]`) |
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.
모든 li태그에 data-action=edit이 들어가는 것 같은데,
li 태그를 data-action=edit으로 선택하는 이유가 있는지, 어떤 걸 구분하기 위해 넣은 속성인지 궁금합니다.
단순히 li태그끼리 구분하기 위해서라면, id로 구분해도 될 것 같아서요!
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.
지금보니 그렇네요!! data-* 관련 attribute 를 사용하는게 익숙하지 않아서, 그랬던게 아닌가 싶습니다. ㅜㅜ 감사합니다!!
| const itemsHtmlString = items.reduce((acc, item) => { | ||
| const { _id, content, isCompleted } = item | ||
| const todoItemTemplate = ` | ||
| <li ${isCompleted && 'class="completed"'} data-action=${EDIT}-${_id}> |
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.
completed가 false일 때, li 태그에 false라는 attribute가 적용됩니다.
{ completed ? class="completed" : "" }로 바꾸면 없어질거에요.
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.
더 짧게 쓸 생각만 햇었네요 ㅜㅜ 적용하겠습니다!!
| const todoItemTemplate = ` | ||
| <li ${isCompleted && 'class="completed"'} data-action=${EDIT}-${_id}> | ||
| <div class="view"> | ||
| <input class="toggle" type="checkbox" data-action=${CHECK}-${_id} ${isCompleted && 'checked'}> |
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.
바로 위의 이슈와 같은 이슈입니다.
{ completed ? "checked" : "" } 로 바꾸는 건 어떨지 제안드립니다
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.
넵!!
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.
용훈님 코드보면서 제가 생각치 못한 구현 방식을 발견하곤 합니다 ㅎㅎ 덕분에 피드백 남기면서 저도 배워갈 수 있는 접근 방식이 많은 것 같아요 :)
몇가지 피드백 남겼는데 리팩토링 작업하실 때 mission002인 경우 mission001에 dependecy가 걸리지 않게, mission002 directory를 따로 만들어서 작업을 진행해주셔야 이전 미션의 merge와 상관없이 원활하게 진행하실 수 있을 것 같아요 :)
| }) | ||
|
|
||
| this.$todoList.addEventListener('click', async (e) => { | ||
| const { CHECK, REMOVE } = dataActions |
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.
addEventListener에 바인딩하는 구현부분을 따로 함수로 빼면 어떨까요?
지금 같은 경우는 $todoList를 click했을 때 어떤 처리를 해주는지 구현부분을 모두 읽어봐야 확인할 수 있는데 만약 this.$todoList.addEventListener('click', eventDispatch)와 같은 형태로 처리해주면 구현 부분을 모두 읽지 않아도
클릭이벤트에 해당하는 내용을 보다 쉽게 알 수 있을 것 같아요 :)
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.
eventHandler 모두 별도로 분리하였습니다!
| } | ||
|
|
||
| TodoList.prototype.renderByFilter = async function() { | ||
| const res = await getTodoList(this.username) |
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.
res 변수를 재사용하지 않는다면, fetch하는 부분에서
fetch(uri, config).then((response) => response.json())
위와 같이 변경하면 보다 좋을 것 같아요~!
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.
바로 다음라인에서 사용합니다!
그리고 리뷰주신 내용은, this.item = await fetch(uri, config).then(res => res.json()) 와 같이 사용하란 말씀이신가요??
| this.renderCounterContainer(items) | ||
| } | ||
|
|
||
| TodoList.prototype.renderCounterContainer = function(items) { |
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.
line 89에서는 countContainer라고 되어있는데, Counter or Count로 통일시키면 더 일관될 것 같아요~!
그리고 실제 render하는 것은 counterContainer가 아니라, count 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.
환결성정 다음으로 네이밍이 세상에서 제일 어려운 것 같습니다.ㅜㅜ
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.
저도 너무 어렵네요 ㅠㅠ 네이밍 잘하게 되면 같이 작명소를 지어봐요 ㅠㅠ
| } | ||
|
|
||
| TodoList.prototype.toggleState = function(id) { | ||
| this.items = this.items.map((item) => id == item.id ? ({...item, completed: !item.completed}) : ({...item})) |
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.
혹시 id 비교를 ===가 아닌 ==로 하신 이유가 있으실까요~? 👀
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.
item.id 는 number 이고, id 는 string 이라 일부러 == 로 했습니다. 음.. 나쁜 방법일까요? ㅜㅜ
| await this.renderByFilter() | ||
| } | ||
|
|
||
| TodoList.prototype.removeState = async function(id) { |
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.
toggleState의 경우 상태를 toggle한다는 의미가 적절한 것 같은데
removeState는 상태를 remove한다는 것으로 오해할 수 있는 여지가 있는 것 같습니다 ㅠㅠ
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.
네이밍 추천 부탁드립니다...ㅜㅜ
mission002/YongHoonJJo/js/app.js
Outdated
| import TodoList from './TodoList.js' | ||
|
|
||
| function App(inputSelector, todoListSelector) { | ||
| this.index = 0 |
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.
사용하지 않는 변수라면 없어도 괜찮을 것 같습니다 :)
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.
api 적용하면서 뺏어야 했는데, 못본 것 같습니다!! 감사합니다!!
| } | ||
|
|
||
| TodoList.prototype.toggleEditView = function(id) { | ||
| const $liElement = document.querySelector(`li[data-action=edit-${id}]`) |
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.
$표시로 dom Element인 것을 나타내므로 변수명에 *Element는 없어도 괜찮지 않을까요~?
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.
$ 는 로토가 제안해준 방식이다보니 적용한건데, 제가 아직 적응되지 않았던 모양입니다. ㅎㅎ 적용하겠습니다!!
| this.$todoList.addEventListener('dblclick', (e) => { | ||
| const { EDIT } = dataActions | ||
| const datasetAction = e.target.dataset.action | ||
| if(!datasetAction) return | ||
|
|
||
| const [action, id] = datasetAction.split('-') | ||
| switch(action) { | ||
| case EDIT: this.toggleEditView(id); break | ||
| } | ||
| }) | ||
| } |
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.
api를 이용할 때에도 에디트 기능을 추가하는 것이 아니시면 삭제해도 되지 않을까 생각합니다.
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.
제가 이해가 잘 안되서 그러는데요ㅜ 좀더 자세하게 설명해주실 수 있을까요?
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.
제가 미션1 파일인 줄 모르고 이곳에 리뷰를 남겨서 혼동을 일으켜 드렸네요.
할일목록을 더블클릭하였을 때, 할일 내용이 POST 메소드를 이용하여 수정되는 것이 아니라면 수정기능을 삭제 해도 되지 않을까 싶어서 코멘트를 남겨보았었습니다.
제가 브랜치 생성하는 과정을 착각해서, 미션2를 이렇게 진행한 것 같습니다. 다음부터는 브랜치 잘 생성해서 진행하겠습니다 .ㅜㅜ 리뷰 감사합니다!! |
|
@EastjunDev
mission1 머지 되면, mission2 에도 mission1 에서 변경된 사항 적용한다음 머지시키면 문제 없을 것 같습니다. 라고 해주신 부분은 이해가 잘 안되서, 답글 남겼는데, 아직 답변이 없으셔서 이 내용에 대해서는 적용하지 못하였습니다.ㅜㅜ ===가 아닌 ==로 하신 이유에 대한 문의도, 답글 남겼는데, 아직 답변이 없으셔서 적용하지 못했습니다!! 리뷰 감사합니다!!!! |
#7 fetch를 이용해 데이터 CRUD 하기
mission01 작업한 곳에서 브랜치를 생성했는데, 기존 미션이 머지가 되지 않아, Mission02 로 된 부분을 보셔야 할 것 같습니다. ㅜㅜ