@@ -90,8 +90,31 @@ by opening a question you help _everyone_ learn more effectively!
90
90
91
91
### ` Elm ` (_ ish_ ) ?
92
92
93
- ` Elm ` (_ ish_ )
93
+ In order to _ simplify_ the code for our Todo List App,
94
+ we _ abstracted_ much of the "_ generic_ " code
95
+ into a "front-end micro framework" called ` Elm ` (_ ish_ ).
96
+ The functions & functionality of ` Elm ` (_ ish_ ) should be _ familiar_ to you
97
+ so you _ should_ be able to build the Todo List using the ` Elm ` (_ ish_ )
98
+ helper functions e.g: ` mount ` , ` div ` , ` input ` and ` route ` .
99
+
100
+ You can _ opt_ to _ either_ :
101
+ ** a)** read the ` Elm ` (_ ish_ ) docs/tutorial
94
102
[ ` elmish.md ` ] ( https://github.com/dwyl/learn-elm-architecture-in-javascript/blob/master/elmish.md )
103
+ *** ` before ` *** building the Todo List App -
104
+ this will give you both TDD practice
105
+ and a deeper understanding of building a micro framework.
106
+ i.e. "** _ prospective_ learning** "<br />
107
+ ** b)** refer the ` Elm ` (_ ish_ ) docs/tutorial
108
+ [ ` elmish.md ` ] ( https://github.com/dwyl/learn-elm-architecture-in-javascript/blob/master/elmish.md )
109
+ *** ` while ` *** building the Todo List App when you "** _ need_ to know** "
110
+ how one of the helper functions works. i.e. "** _ contextual_ learning** " <br />
111
+ ** c)** ** only _ consult_ ** the ` Elm ` (_ ish_ ) docs/tutorial
112
+ [ ` elmish.md ` ] ( https://github.com/dwyl/learn-elm-architecture-in-javascript/blob/master/elmish.md )
113
+ *** ` if ` *** you are "stuck" *** ` while ` *** building the Todo List App.
114
+ i.e. "** _ debug_ learning** " <br />
115
+
116
+ The choice is yours; there is no "right" way.
117
+
95
118
96
119
97
120
### Testing?
110
133
[ ** front-end** -with-tape.md] ( https://github.com/dwyl/learn-tape/blob/master/front-end-with-tape.md )
111
134
112
135
113
- ### Create Files
136
+ #### Create Files
114
137
115
138
In your editor/terminal create the following files:
116
139
@@ -123,7 +146,7 @@ Todo List App.
123
146
` todo-app.js ` is where all the JSDOCs and functions
124
147
for our Todo List App will be written.
125
148
126
- ### Test Setup
149
+ #### Test Setup
127
150
128
151
In order to run our test(s), we need some "setup" code
129
152
that "requires" the libraries/files so we can _ execute_ the functions.
@@ -153,30 +176,51 @@ you should see no output.
153
176
154
177
155
178
179
+
156
180
### ` model `
157
181
158
182
The ` model ` for our Todo List App is remarkably simple.
159
- All we need is an ` Object ` containing two keys:
183
+ All we need is an ` Object ` containing two keys ` todos ` and ` hash ` :
160
184
161
185
``` js
162
186
{
163
187
todos: [
164
- { id: 1 , title: " Learn Elm Architecture" , completed : true },
165
- { id: 2 , title: " Build Todo List App" , completed : false },
166
- { id: 3 , title: " Win the Internet!" , completed , false }
188
+ { id: 1 , title: " Learn Elm Architecture" , done : true },
189
+ { id: 2 , title: " Build Todo List App" , done : false },
190
+ { id: 3 , title: " Win the Internet!" , done , false }
167
191
],
168
192
hash: ' #/active' // the "route" to display
169
193
}
170
194
```
171
195
196
+
197
+
172
198
#### What about ` metadata ` ?
173
199
174
- Rather than storing "metadata"
200
+ > Metadata is a set of data that describes
201
+ and gives information about other data.
202
+ https://en.wikipedia.org/wiki/Metadata
203
+
204
+ There are two types of ` metadata ` in a Todo List App:
205
+ + ` id ` - each todo item has an ` id ` , this is the item's position in the list.
206
+ + count - the count of items according to their state of _ completion_ .
207
+ e.g: in the model above there are
208
+ 2 items which are "active"
209
+ and 1 which is "done".
210
+
211
+ Rather than _ storing_ "metadata" in the model
175
212
(_ e.g: the count of active and completed Todo items_ )
176
- we will "compute" (derive) what we _ need _ at "runtime",
177
- this may "waste" a few CPU cycles, but that's "OK"!
213
+ we will "compute" (derive) it "runtime" to keep the ` model ` simple.
214
+ This may "waste" a few CPU cycles computing the count but that's "OK"!
178
215
Even on an _ ancient_ Android device
179
- this will only take a milisecond to compute
216
+ this will only take a millisecond to compute,
217
+ will not "slow down" the app or affect UX.
218
+
219
+
220
+
221
+
222
+
223
+
180
224
181
225
182
226
0 commit comments