@@ -2,18 +2,20 @@ import Header from "./components/Header.js";
22import TodoForm from "./components/TodoForm.js" ;
33import TodoList from "./components/TodoList.js" ;
44import TodoCount from "./components/TodoCount.js" ;
5- import { setItem } from "./utils/storage.js" ;
5+ import { setItem , getItem } from "./utils/storage.js" ;
66import { TodoCount as TodoCnt , TodoList as TodoLi } from "./types/todo.js" ;
7-
87export default class App {
98 private readonly todoList : TodoList ;
109 private readonly todoCount : TodoCount ;
10+ private readonly initialState : TodoLi ;
11+ private readonly initialCount : TodoCnt ;
1112
1213 constructor (
1314 private readonly $target : HTMLElement ,
14- private readonly initialState : TodoLi ,
15- private readonly initialCount : TodoCnt
1615 ) {
16+ this . initialState = getItem ( "todo" , [ ] ) ;
17+ this . initialCount = getItem ( "count" , { total : 0 , done : 0 } ) ;
18+
1719 new Header ( $target , "Todo List" ) ;
1820
1921 new TodoForm (
@@ -29,11 +31,11 @@ export default class App {
2931
3032 this . todoList = new TodoList (
3133 $target ,
32- initialState ,
34+ this . initialState ,
3335 ( state : TodoLi ) => this . #updateCount( state )
3436 ) ;
3537
36- this . todoCount = new TodoCount ( $target , initialCount ) ;
38+ this . todoCount = new TodoCount ( $target , this . initialCount ) ;
3739 }
3840
3941 // 카운트 업데이트
0 commit comments