1
1
// Tutorial 3 - about-state-and-meet-redux.js
2
2
3
- // Sometimes, the actions that we'll handle in our application will not only be made to inform us
4
- // that something happened but also to tell us that a data needs to be updated.
3
+ // Sometimes the actions that we'll handle in our application will not only inform us
4
+ // that something happened but also tell us that data needs to be updated.
5
5
6
6
// This is actually quite a big challenge in any apps.
7
7
// Where do I keep all the data regarding my application along its lifetime?
12
12
13
13
// Redux (https://github.com/gaearon/redux) is a "predictable state container for JavaScript apps"
14
14
15
- // Let's take again those questions above and reply to them with
15
+ // Let's review the above questions and reply to them with
16
16
// Redux vocabulary (flux vocabulary too for some of them):
17
17
18
18
// Where do I keep all the data regarding my application along its lifetime?
19
19
// You keep it the way you want (JS object, array, Immutable structure, ...).
20
20
// Data of your application will be called state. Makes sense since we're talking about
21
- // all the application's data that will evolve over time, it's really the application's state.
21
+ // all the applications data that will evolve over time, it's really the applications state.
22
22
// But you hand it over to Redux (Redux is "state container", remember?).
23
23
// How do I handle modification of such data?
24
24
// Using reducers.
28
28
// How do I propagate modifications to all parts of my application?
29
29
// Using subscribers to state's modifications.
30
30
31
- // Redux tie all this up together for you.
31
+ // Redux ties all this together for you.
32
32
// To sum up, Redux will provide you:
33
33
// 1) a place to put your application state
34
34
// 2) a mechanism to subscribe to state updates
35
- // 3) a mechanism to dispatch actions to modifiers of your application state AKA reducers
35
+ // 3) a mechanism to dispatch actions to modifiers of your application state, AKA reducers
36
36
37
37
// The Redux instance is called a store and can be created like this:
38
38
/*
39
39
import { createStore } from 'redux'
40
40
var store = createStore()
41
41
*/
42
42
43
- // but if you run the code above, you'll notice that it throw an error:
43
+ // But if you run the code above, you'll notice that it throw an error:
44
44
// Error: Invariant Violation: Expected the reducer to be a function.
45
45
46
- // That's because createStore expect at least a function that will allow him to reduce your state
46
+ // That's because createStore expects a function that will allow it to reduce your state.
47
47
48
48
// Let's try again
49
49
@@ -53,4 +53,4 @@ var store = createStore(() => {})
53
53
54
54
// Seems good for now...
55
55
56
- // Go to next tutorial: simple-reducer.js
56
+ // Go to next tutorial: simple-reducer.js
0 commit comments