34
34
*/
35
35
36
36
// As you can see above, a middleware is made of 3 nested functions (that will get called sequentially):
37
- // 1) The first level provide the dispatch function and a getState function (if your
37
+ // 1) The first level provides the dispatch function and a getState function (if your
38
38
// middleware or your action creator needs to read data from state) to the 2 other levels
39
- // 2) The second level provide the next function that will allow you to explicitly hand over
39
+ // 2) The second level provides the next function that will allow you to explicitly hand over
40
40
// your transformed input to the next middleware or to Redux (so that Redux can finally call all reducers).
41
41
// 3) the third level provides the action received from the previous middleware or from your dispatch
42
42
// and can either trigger the next middleware (to let the action continue to flow) or process
43
43
// the action in any appropriate way.
44
44
45
45
// Those of you who are trained to functional programming may have recognized above an opportunity
46
46
// to apply a functional pattern: currying (if you aren't, don't worry, skipping the next 10 lines
47
- // won't affect your redux understanding). Using currying, you could simplify the above function like that:
47
+ // won't affect your Redux understanding). Using currying, you could simplify the above function like that:
48
48
/*
49
- // "curry" may come any functional programming library (lodash, ramda, etc.)
49
+ // "curry" may come from any functional programming library (lodash, ramda, etc.)
50
50
var thunkMiddleware = curry(
51
51
({dispatch, getState}, next, action) => (
52
52
// your middleware-specific code goes here
@@ -79,7 +79,7 @@ var thunkMiddleware = function ({ dispatch, getState }) {
79
79
// store that applies middleware to a store's dispatch".
80
80
// (from https://github.com/rackt/redux/blob/v1.0.0-rc/src/utils/applyMiddleware.js)
81
81
82
- // Here is how you would integrate a middleware to your Redux store:
82
+ // Here is how you would integrate a middleware into your Redux store:
83
83
84
84
import { createStore , combineReducers , applyMiddleware } from 'redux'
85
85
@@ -144,7 +144,7 @@ function logMiddleware ({ dispatch, getState }) {
144
144
}
145
145
}
146
146
147
- // Same below for a middleware to discard all actions that goes through (not very useful as is
147
+ // Same below for a middleware to discard all actions that are dispatched (not very useful as is
148
148
// but with a bit of more logic it could selectively discard a few actions while passing others
149
149
// to next middleware or Redux):
150
150
function discardMiddleware ( { dispatch, getState } ) {
@@ -161,7 +161,7 @@ function discardMiddleware ({ dispatch, getState }) {
161
161
// const finalCreateStore = applyMiddleware(discardMiddleware, thunkMiddleware)(createStore)
162
162
// should make your actions never reach your thunkMiddleware and even less your reducers.
163
163
164
- // See http://rackt.org/redux/docs/introduction/Ecosystem.html, section Middlewares , to
164
+ // See http://rackt.org/redux/docs/introduction/Ecosystem.html, section Middleware , to
165
165
// see other middleware examples.
166
166
167
167
// Let's sum up what we've learned so far:
@@ -170,7 +170,7 @@ function discardMiddleware ({ dispatch, getState }) {
170
170
// 3) We know how to handle custom actions like asynchronous actions thanks to middlewares
171
171
172
172
// The only missing piece to close the loop of Flux application is to be notified about
173
- // state updates to be able to react to them (by re-rendering our components for example).
173
+ // state updates in order to react to them (by re-rendering our components for example).
174
174
175
175
// So how do we subscribe to our Redux store updates?
176
176
0 commit comments