5858import { Component , Vue , Watch } from ' vue-property-decorator'
5959
6060import Todo from ' ./Todo'
61- import TodoStore from ' ./TodoStore'
6261
6362Vue .filter (' pluralize' , (n : number ): string => {
6463 return n === 1 ? ' item' : ' items'
@@ -74,8 +73,6 @@ Vue.directive('todo-focus', (el, binding) => {
7473 name: ' app'
7574})
7675export default class App extends Vue {
77- private store = TodoStore ()
78-
7976 private visibility: string = ' all'
8077
8178 private newTodo: string = ' '
@@ -89,23 +86,23 @@ export default class App extends Vue {
8986 }
9087
9188 get todos(): Todo [] {
92- return this .store .getters .all
89+ return this .$ store .getters .all
9390 }
9491
9592 get filteredTodos(): Todo [] {
96- return this .store .getters [this .visibility ]
93+ return this .$ store .getters [this .visibility ]
9794 }
9895
9996 get remaining(): number {
100- return this .store .getters .active .length
97+ return this .$ store .getters .active .length
10198 }
10299
103100 get allDone(): boolean {
104101 return this .remaining === 0
105102 }
106103
107104 set allDone(value : boolean ) {
108- this .store .commit (' toggleAll' , value )
105+ this .$ store .commit (' toggleAll' , value )
109106 }
110107
111108 addTodo() {
@@ -114,13 +111,13 @@ export default class App extends Vue {
114111 return
115112 }
116113
117- this .store .commit (' add' , title )
114+ this .$ store .commit (' add' , title )
118115
119116 this .newTodo = ' '
120117 }
121118
122119 removeTodo(todo : Todo ) {
123- this .store .commit (' remove' , todo )
120+ this .$ store .commit (' remove' , todo )
124121 }
125122
126123 editTodo(todo : Todo ) {
@@ -137,7 +134,7 @@ export default class App extends Vue {
137134
138135 todo .title = todo .title .trim ()
139136 if (todo .title ) {
140- this .store .commit (' update' , todo )
137+ this .$ store .commit (' update' , todo )
141138 } else {
142139 this .removeTodo (todo )
143140 }
@@ -149,17 +146,17 @@ export default class App extends Vue {
149146 }
150147
151148 toggleTodo(todo : Todo ) {
152- this .store .commit (' toggle' , todo )
149+ this .$ store .commit (' toggle' , todo )
153150 }
154151
155152 removeCompleted() {
156- this .store .commit (' removeCompleted' )
153+ this .$ store .commit (' removeCompleted' )
157154 }
158155
159156 onHashChange() {
160157 const visibility = window .location .hash .replace (/ #\/ ? / , ' ' )
161158
162- if (this .store .getters [visibility ]) {
159+ if (this .$ store .getters [visibility ]) {
163160 this .visibility = visibility
164161 } else {
165162 window .location .hash = ' '
0 commit comments