@@ -188,7 +188,7 @@ All we need is an `Object` containing two keys `todos` and `hash`:
188
188
{ id: 2 , title: " Build Todo List App" , done: false },
189
189
{ id: 3 , title: " Win the Internet!" , done, false }
190
190
],
191
- hash: ' #/active ' // the "route" to display
191
+ hash: ' #/' // the "route" to display
192
192
}
193
193
```
194
194
` todos ` is an ` Array ` of ` Objects ` and each Todo (Array) item
@@ -206,10 +206,10 @@ https://en.wikipedia.org/wiki/Metadata
206
206
207
207
There are two types of ` metadata ` in a Todo List App:
208
208
+ ` id ` - each todo item has an ` id ` , this is the item's position in the list.
209
- + count - the count of items according to their state of _ completion_ .
210
- e.g: in the model above there are
211
- 2 items which are "active"
212
- and 1 which is "done".
209
+ + ` count ` - the count of items according to their state of _ completion_ .
210
+ e.g: in the model above there are 3 todo items in the ` todos ` Array;
211
+ 2 items which are "active" ( ` done=false ` )
212
+ and 1 which is "done" ( ` done=true ` ) .
213
213
214
214
Rather than _ storing_ "metadata" in the model
215
215
(_ e.g: the count of active and completed Todo items_ )
@@ -666,6 +666,51 @@ of the `TOGGLE case` in `upadate` until _all_ tests pass:
666
666
667
667
![ undo-a-todo-item] ( https://user-images.githubusercontent.com/194400/43686533-b25d4608-98bf-11e8-809e-1153fcfb1db1.png )
668
668
669
+ ### ` view ` Function
670
+
671
+ It won't have "_ escaped_ " you that _ so far_ we have not written _ any_ code
672
+ that a _ user_ can actually _ interact_ with.
673
+
674
+ _ So far_ we have _ successfully_ added two ` case ` blocks in the ` switch ` statement
675
+ of our ` update ` function. We now have the two _ basic_ functions required
676
+ to both ` ADD ` a new todo list item to the ` model.todos ` Array
677
+ _ and_ check-off a todo list item as "done" using the ` TOGGLE action ` .
678
+ This is "_ enough_ " functionality to start _ using_ the todo list (_ ourselves_ )
679
+ and ** UX-testing** it with _ prospective_ "*** users*** ".
680
+
681
+ If you followed through the "Elm(ish)" tutorial
682
+ [ ` elmish.md ` ] ( https://github.com/dwyl/learn-elm-architecture-in-javascript/blob/master/elmish.md )
683
+ you will have seen that we created a _ sample_ ` view ` in the last few _ tests_
684
+ to "_ exercise_ " the DOM element creation functions.
685
+ This means that we _ already know_ how to build a ` view ` for our Todo List App!
686
+ We "_ just_ " need to _ adapt_ the ` view ` we made in ` Elm ` (_ ish_ ) to display
687
+ the data in our ` model ` .
688
+
689
+ #### Sample ` model ` to Render in Our ` view `
690
+
691
+ Let's return to the sample ` model ` from above:
692
+
693
+ ``` js
694
+ {
695
+ todos: [
696
+ { id: 1 , title: " Learn Elm Architecture" , done: true },
697
+ { id: 2 , title: " Build Todo List App" , done: false },
698
+ { id: 3 , title: " Win the Internet!" , done, false }
699
+ ],
700
+ hash: ' #/' // the "route" to display
701
+ }
702
+ ```
703
+ The model contains _ three_ items in the ` todos ` Array. <br />
704
+ The first is complete (` done=true ` )
705
+ whereas the second and third items are still "todo" (` done=false ` ).
706
+
707
+ This is what this ` model ` looks like in the "VanillaJS"
708
+ TodoMVC:
709
+ echo ![ todomvc-3-items-1-done] ( https://user-images.githubusercontent.com/194400/43689907-e9caa548-98f8-11e8-8fd1-7b63e7fc5e30.png )
710
+
711
+ Our quest in the next "pomodoro" is to re-create this
712
+ using the DOM functions we created in ` Elm ` (_ ish_ )!
713
+
669
714
670
715
<!--
671
716
0 commit comments