Skip to content

Commit f2aeb2e

Browse files
committed
adds prerequisites and recommended reading sections #5
1 parent b56d6a3 commit f2aeb2e

File tree

1 file changed

+63
-28
lines changed

1 file changed

+63
-28
lines changed

README.md

+63-28
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ Once you have had a "play" with the demo, come back and _build_ it!!
3838

3939
## Why?
4040

41-
The _purpose_ of this **Todo List _mini_ project** is to
41+
The _purpose_ of this **Todo List _mini_ project**
42+
is to _practice_ your "VanillaJS" skills and
4243
_consolidate_ your understanding of The Elm Architecture (TEA)
4344
by creating a "real world" _useable_ App following _strict_
4445
Documentation and Test Driven Development.
@@ -62,18 +63,23 @@ Thankfully, by the end of this chapter, you will see how **easy** it is._
6263

6364
## What?
6465

65-
_Use_ our "TEA" knowledge to build a simple "Todo List" Application. <br />
66+
Build a fully functional "Todo List" Application! <br />
6667
Along the way we will cover:
6768

6869
+ [x] Building an App using a pre-made CSS Styles/Framework!
69-
+ [x] The Document Object Model (DOM)
70+
+ [x] The Document Object Model (DOM) + JSDOM
7071
+ [x] Browser Routing/Navigation
7172
+ [x] Local Storage for Offline Support
7273
+ [x] Keyboard event listeners for rapid todo list creation and editing!
7374

74-
We will be abstracting all "TEA" related ("generic") code
75-
into a file called **`elmish.js`**
76-
so that our Todo List application can be as concise
75+
We will be abstracting all "architecture" related ("generic") code
76+
into a "mini frontend framework" called "***elmish***".
77+
(_elmish is inspired by Elm but only meant for educational purposes!_)
78+
79+
The journey to creating **elmish** is captured in
80+
[**`elmish.md`**](https://github.com/dwyl/todomvc-vanilla-javascript-elm-architecture-example/blob/master/elmish.md)
81+
and fully documented code is in **`elmish.js`**.
82+
This means our Todo List App can be as concise
7783
and "declarative" as possible.
7884

7985
### Todo List?
@@ -83,9 +89,10 @@ they are a way of keeping a list of the tasks that need to be done. <br />
8389
see: https://en.wikipedia.org/wiki/Time_management#Setting_priorities_and_goals
8490

8591
Todo Lists or "Checklists" are the _best_ way of tracking tasks. <br />
86-
Atul Gawande wrote a _superb_ book on this subject:
92+
Atul Gawande wrote a _superb_ book on this subject: <br />
8793
https://www.amazon.com/Checklist-Manifesto-How-Things-Right/dp/0312430000 <br />
88-
Watch: https://www.youtube.com/results?search_query=checklist+manifesto
94+
Or if you don't have time to read,
95+
watch: https://www.youtube.com/results?search_query=checklist+manifesto
8996

9097
### TodoMVC?
9198

@@ -112,16 +119,46 @@ This tutorial is for anyone/everyone who wants
112119
to develop their "core" JavaScript skills (_without using a framework/library_)
113120
while building a "real world" (_fully functional_) Todo List Application.
114121

115-
to _apply_ their "TEA" knowledge
116-
and _think_ about the basics of a
117-
118122
> As always, if you get "stuck", _please_ open an issue:
119-
https://github.com/dwyl/learn-elm-architecture-in-javascript/issues
123+
https://github.com/dwyl/todomvc-vanilla-javascript-elm-architecture-example/issues
120124
by opening a question you help _everyone_ learn more effectively!
121125

122126

127+
### Prerequisites
128+
129+
Most beginners with basic JavaScript and HTML knowledge
130+
should be able to follow this example without any prior experience.
131+
The code is commented and the most "complex" function is an event listener.
132+
With that said, if you feel "stuck" at any point,
133+
please consult the recommend reading (_and Google_)
134+
and if you cannot find an answer,
135+
please open an issue!
136+
137+
### Recommended reading:
138+
139+
+ Test Driven Developement: https://github.com/dwyl/learn-tdd
140+
+ Tape-specific syntax: https://github.com/dwyl/learn-tape
141+
+ Elm Architecture: https://github.com/dwyl/learn-elm-architecture-in-javascript
142+
143+
123144
## _How?_
124145

146+
147+
Start by cloning this repository to your `localhost`
148+
so that you can follow the example/tutorial offline:
149+
150+
```sh
151+
git clone https://github.com/dwyl/todomvc-vanilla-javascript-elm-architecture-example.git
152+
```
153+
154+
Install the `devDependencies` so you can run the tests:
155+
```sh
156+
cd todomvc-vanilla-javascript-elm-architecture-example && npm install
157+
```
158+
159+
Now you have _everything_ you need to build a Todo List from scratch!
160+
161+
125162
### `Elm`(_ish_) ?
126163

127164
In order to _simplify_ the code for our Todo List App,
@@ -177,8 +214,8 @@ and
177214
In your editor/terminal create the following files:
178215

179216
+ `test/todo-app.test.js`
180-
+ `examples/todo-list/todo-app.js`
181-
+ `examples/todo-list/index.html`
217+
+ `lib/todo-app.js`
218+
+ `index.html`
182219

183220
These file names should be self-explanatory, but if unclear,
184221
`todo-app.test.js` is where we will write the tests for our
@@ -193,20 +230,19 @@ that "requires" the libraries/files so we can _execute_ the functions.
193230

194231
In the `test/todo-app.test.js` file, type the following code:
195232
```js
196-
const test = require('tape'); // https://github.com/dwyl/todomvc-vanilla-javascript-elm-architecture-example
233+
const test = require('tape'); // https://github.com/dwyl/learn-tape
197234
const fs = require('fs'); // to read html files (see below)
198235
const path = require('path'); // so we can open files cross-platform
199-
const html = fs.readFileSync(path.resolve(__dirname,
200-
'../examples/todo-list/index.html')); // sample HTML file to initialise JSDOM.
236+
const html = fs.readFileSync(path.resolve(__dirname, '../index.html'));
201237
require('jsdom-global')(html); // https://github.com/rstacruz/jsdom-global
202-
const app = require('../examples/todo-list/todo-app.js'); // functions to test
238+
const app = require('../lib/todo-app.js'); // functions to test
203239
const id = 'test-app'; // all tests use 'test-app' as root element
204240
```
205241

206242
> Most of this code should be _familiar_ to you
207243
if you have followed previous tutorials.
208244
> If anything is _unclear_ please revisit
209-
[https://github.com/dwyl/**todomvc-vanilla-javascript-elm-architecture-example**](https://github.com/dwyl/todomvc-vanilla-javascript-elm-architecture-example)
245+
[https://github.com/dwyl/**learn-tape**](https://github.com/dwyl/learn-tape)
210246
and
211247
[**front-end**-with-tape.md](https://github.com/dwyl/todomvc-vanilla-javascript-elm-architecture-example/blob/master/front-end-with-tape.md)
212248

@@ -215,7 +251,6 @@ you should see no output. <br />
215251
(_this is expected as we haven't written any tests yet!_)
216252

217253

218-
219254
### `model`
220255

221256
The `model` for our Todo List App is **_boringly_ simple**.
@@ -257,7 +292,7 @@ we will "compute" (derive) it "at runtime" to keep the `model` simple.
257292
This may "waste" a few CPU cycles computing the count but that's "OK"!
258293
Even on an _ancient_ Android device
259294
this will only take a millisecond to compute and
260-
will not "slow down" the app or affect UX.
295+
won't "slow down" the app or affect UX.
261296

262297

263298
#### `model` _Test_
@@ -1324,7 +1359,7 @@ into a functioning app!
13241359

13251360
### Mount the App in `index.html`
13261361

1327-
Open your **`/examples/todo-list/index.html`** file
1362+
Open your **`index.html`** file
13281363
and ensure that the following lines are in the **`<body>`**:
13291364

13301365
```html
@@ -1354,11 +1389,11 @@ and ensure that the following lines are in the **`<body>`**:
13541389
```
13551390

13561391
For a complete "snapshot" of the `index.html` file here,
1357-
see: [**`examples/todo-list/index.html`**](https://github.com/dwyl/learn-elm-architecture-in-javascript/blob/ef56c490a48db8a900f1832d0cc373b75838b4d4/examples/todo-list/index.html)
1392+
see: [**`index.html`**](https://github.com/dwyl/learn-elm-architecture-in-javascript/blob/ef56c490a48db8a900f1832d0cc373b75838b4d4/examples/todo-list/index.html)
13581393

13591394

13601395
If you run the project with command **`npm start`**
1361-
and navigate to: http://127.0.0.1:8000/examples/todo-list
1396+
and navigate to: http://127.0.0.1:8000/
13621397

13631398
You should see:
13641399
![view-working](https://user-images.githubusercontent.com/194400/43786145-e476bdd0-9a5f-11e8-9043-cf997be615ae.png)
@@ -1571,7 +1606,7 @@ if you need a recap, see:
15711606

15721607
Try to make the "**2. New Todo**" batch of tests _pass_
15731608
by creating (_and exporting_) a **`subscriptions`** function
1574-
in your **`examples/todo-list/todo-app.js`** file.
1609+
in your **`lib/todo-app.js`** file.
15751610

15761611
If you get "_stuck_", checkout the sample code:
15771612
[**`todo-app.js > subscriptions`**](https://github.com/dwyl/learn-elm-architecture-in-javascript/pull/45/files#diff-6be3e16fe7cfb4c00788d4d587374afdR320)
@@ -1693,7 +1728,7 @@ function to include `signal('TOGGLE_ALL')` in the attributes array.
16931728

16941729
Try and make this test pass by yourself before consulting the
16951730
sample code:
1696-
[**`examples/todo-list/todo-app.js`**](https://github.com/dwyl/learn-elm-architecture-in-javascript/pull/45/files#diff-6be3e16fe7cfb4c00788d4d587374afdR46)
1731+
[**`lib/todo-app.js`**](https://github.com/dwyl/learn-elm-architecture-in-javascript/pull/45/files#diff-6be3e16fe7cfb4c00788d4d587374afdR46)
16971732

16981733

16991734
### 4. Item (Toggle, Edit & Delete)
@@ -2196,7 +2231,7 @@ But we are building a _visual_ application and are not _seeing_ anything ...
21962231

21972232
Let's take a _brief_ detour to _visualise_ the progress we have made.
21982233

2199-
Open the `examples/todo-list/index.html` file
2234+
Open the `index.html` file
22002235
and alter the contents of the `<script>` tag:
22012236
```html
22022237
<script>
@@ -2217,7 +2252,7 @@ Then in your terminal, start the live-server:
22172252
```sh
22182253
npm start
22192254
```
2220-
In your browser, vist: http://127.0.0.1:8000/examples/todo-list/ <br />
2255+
In your browser, vist: http://127.0.0.1:8000/ <br />
22212256
You should see that the _third_ todo list item is in "**editing _mode_**":
22222257

22232258
![elm-todomvc-editing-item](https://user-images.githubusercontent.com/194400/45180706-0eab5680-b214-11e8-9dcf-a8c4476e4b11.png)

0 commit comments

Comments
 (0)