You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+19-12Lines changed: 19 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -11,20 +11,11 @@ Thunk [middleware](http://rackt.github.io/redux/docs/advanced/Middleware.html) f
11
11
npm install --save redux-thunk
12
12
```
13
13
14
-
## What’s a thunk?!
15
-
16
-
A [thunk](https://en.wikipedia.org/wiki/Thunk) is a function that wraps an expression to delay its evaluation.
14
+
## Why Do I Need This?
17
15
18
-
```js
19
-
// calculation of 1 + 2 is immediate
20
-
// x === 3
21
-
let x =1+2;
16
+
If you’re not sure whether you need it, you probably don’t.
22
17
23
-
// calculation of 1 + 2 is delayed
24
-
// foo can be called later to perform the calculation
25
-
// foo is a thunk!
26
-
letfoo= () =>1+2;
27
-
```
18
+
**[Read this for an in-depth introduction to thunks in Redux.](http://stackoverflow.com/questions/35411423/how-to-dispatch-a-redux-action-with-a-timeout/35415559#35415559)**
28
19
29
20
## Motivation
30
21
@@ -67,6 +58,22 @@ function incrementIfOdd() {
67
58
}
68
59
```
69
60
61
+
## What’s a thunk?!
62
+
63
+
A [thunk](https://en.wikipedia.org/wiki/Thunk) is a function that wraps an expression to delay its evaluation.
64
+
65
+
```js
66
+
// calculation of 1 + 2 is immediate
67
+
// x === 3
68
+
let x =1+2;
69
+
70
+
// calculation of 1 + 2 is delayed
71
+
// foo can be called later to perform the calculation
0 commit comments