-
Notifications
You must be signed in to change notification settings - Fork 213
[10기 김형남] TodoList with CRUD #215
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
Open
hyoungnam
wants to merge
10
commits into
next-step:hyoungnam
Choose a base branch
from
hyoungnam:main
base: hyoungnam
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
08c6542
feat: :sparkles: 요구사항1 - todo list에 todoItem을 키보드로 입력하여 추가하기
hyoungnam 5e6d51e
feat: :sparkles: 요구사항2 - todo list의 체크박스를 클릭하여 complete 상태로 변경
hyoungnam 7b548bb
refactor: :recycle: todo의 중복로직 리팩토링
hyoungnam 45e3e62
feat: :sparkles: 요구사항4 - todo list의 x버튼을 이용해서 해당 엘리먼트를 삭제
hyoungnam 48331a5
feat: :sparkles: 요구사항5 - todo list의 item갯수를 count한 갯수를 리스트의 하단에 보여주기
hyoungnam 43ff3d1
feat: :sparkles: 요구사항6 - todo list의 상태값을 확인하여 view 바꾸기
hyoungnam a7b0419
refactor: :recycle: TodoList 분리
hyoungnam 07280d5
refactor: :recycle: deleteTodoItem 함수 분리
hyoungnam e5887c5
feat: :sparkles: 심화 요구사항 - localStorage에 데이터를 저장
hyoungnam e6c0e5c
docs: :memo: README 수정
hyoungnam File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| export const get = (key, defaultState) => | ||
| JSON.parse(localStorage.getItem(key)) || defaultState; | ||
| export const set = (key, newState) => | ||
| localStorage.setItem(key, JSON.stringify(newState)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,25 @@ | ||
| export default function Store() { | ||
| //State | ||
| this.state = { | ||
| todos: [], | ||
| view: "all", | ||
| }; | ||
| //Observer | ||
| this.observers = []; | ||
| this.addObserver = (observer) => this.observers.push(observer); | ||
| this.observing = () => | ||
| this.observers.forEach((observer) => observer.render()); | ||
| import { get, set } from "../storage/index.js"; | ||
| const USER = "user"; | ||
|
|
||
| export default class Store { | ||
| constructor() { | ||
| this.state = get(USER, { todos: [], view: "all" }); | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. store에 state를 저장하는 것은 결합이 강하고 역할이 많으니 좀 더 분리 |
||
| this.observers = []; | ||
| } | ||
| addObserver(observer) { | ||
| this.observers.push(observer); | ||
| } | ||
| observing() { | ||
| this.observers.forEach((observer) => observer.render()); | ||
| } | ||
| //GET | ||
| this.getState = () => { | ||
| getState() { | ||
| return this.state; | ||
| }; | ||
| } | ||
| //SET | ||
| this.setState = (newState) => { | ||
| setState(newState) { | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 비즈니스 로직은 상태를 가진 계층에서 처리하기 |
||
| this.state = { ...this.state, ...newState }; | ||
| set(USER, this.state); | ||
| this.observing(); | ||
| }; | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
형남님 코드를 보면서 많이 배울 수 있었습니다 .!! 감사합니다 👍