Skip to content

Commit 248ad58

Browse files
committed
update tutorial for mocha-coderoad@0.10
1 parent 631786f commit 248ad58

File tree

23 files changed

+420
-49
lines changed

23 files changed

+420
-49
lines changed

README.md

Lines changed: 75 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22

33
A [CodeRoad](https://coderoad.github.io) tutorial for learning Redux.
44

5-
<!-- @import('01') -->
6-
<!-- @import('03') -->
7-
<!-- @import('04') -->
8-
<!-- @import('05') -->
9-
<!-- @import('06') -->
10-
<!-- @import('07') -->
115
<!-- @import('08') -->
126
<!-- @import('09') -->
137
<!-- @import('10') -->
@@ -29,10 +23,85 @@ CodeRoad is an open-sourced interactive tutorial platform for the Atom Editor. L
2923

3024
## Outline
3125

26+
##### Project Setup
27+
28+
Getting a project setup is rarely easy. Luckily, we have a quick script that can do the work for us.
29+
30+
---
31+
32+
Running `> npm run setup` will do the following:
33+
34+
1. Install package dev dependencies
35+
2. Create an output directory called "dist"
36+
3. Install "concurrently" & "browser-sync" globally
37+
4. Run our app in the browser
38+
39+
You'll find this "setup" script located in your *package.json*.
40+
41+
42+
---
43+
44+
We'll be installing a lot of scripts from terminal. You may also want to consider installing the atom package ["platformio-ide-terminal"](https://github.com/platformio/platformio-atom-ide-terminal), which provides a terminal inside your editor.
45+
3246
##### The Store
3347

3448
The "single source of truth".
3549

3650
```js
3751
const store = createStore(reducer, initialState);
3852
```
53+
54+
##### Actions
55+
56+
Events that change the data.
57+
58+
##### 1. Actions
59+
```js
60+
const action = { type: 'ACTION_NAME' };
61+
```
62+
63+
##### 2. Action Creators
64+
65+
```js
66+
const actionName = () => ({ type: 'ACTION_NAME' });
67+
```
68+
69+
##### 3. Action Types
70+
71+
```js
72+
const ACTION_NAME = 'ACTION_NAME'
73+
```
74+
75+
##### Reducer
76+
77+
The data transformation
78+
79+
```js
80+
const reducer = (state) => {
81+
console.log(state);
82+
return state;
83+
};
84+
```
85+
86+
##### Pure Functions
87+
88+
Reducers must be pure functions
89+
90+
State is "read only".
91+
92+
Notes
93+
```js
94+
const nextPokemon = state.pokemon.map(p => {
95+
if (id === p.id) {
96+
p.votes += 1;
97+
}
98+
return p;
99+
});
100+
return {
101+
pokemon: nextPokemon
102+
};
103+
```
104+
105+
##### Combine Reducers
106+
107+
Create modular, composable reducers with `combineReducers`.

0 commit comments

Comments
 (0)