Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed Feb 15, 2016
1 parent 879193a commit 68f15eb
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,11 @@ Thunk [middleware](http://rackt.github.io/redux/docs/advanced/Middleware.html) f
npm install --save redux-thunk
```

## What’s a thunk?!

A [thunk](https://en.wikipedia.org/wiki/Thunk) is a function that wraps an expression to delay its evaluation.
## Why Do I Need This?

```js
// calculation of 1 + 2 is immediate
// x === 3
let x = 1 + 2;
If you’re not sure whether you need it, you probably don’t.

// calculation of 1 + 2 is delayed
// foo can be called later to perform the calculation
// foo is a thunk!
let foo = () => 1 + 2;
```
**[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)**

## Motivation

Expand Down Expand Up @@ -67,6 +58,22 @@ function incrementIfOdd() {
}
```

## What’s a thunk?!

A [thunk](https://en.wikipedia.org/wiki/Thunk) is a function that wraps an expression to delay its evaluation.

```js
// calculation of 1 + 2 is immediate
// x === 3
let x = 1 + 2;

// calculation of 1 + 2 is delayed
// foo can be called later to perform the calculation
// foo is a thunk!
let foo = () => 1 + 2;
```


## Installation

```
Expand Down

0 comments on commit 68f15eb

Please sign in to comment.