redux-thunk
Advanced tools
Comparing version 2.1.0 to 2.1.1
@@ -69,4 +69,4 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
return function (_ref) { | ||
var dispatch = _ref.dispatch; | ||
var getState = _ref.getState; | ||
var dispatch = _ref.dispatch, | ||
getState = _ref.getState; | ||
return function (next) { | ||
@@ -73,0 +73,0 @@ return function (action) { |
function createThunkMiddleware(extraArgument) { | ||
return function (_ref) { | ||
var dispatch = _ref.dispatch; | ||
var getState = _ref.getState; | ||
var dispatch = _ref.dispatch, | ||
getState = _ref.getState; | ||
return function (next) { | ||
@@ -6,0 +6,0 @@ return function (action) { |
@@ -6,4 +6,4 @@ 'use strict'; | ||
return function (_ref) { | ||
var dispatch = _ref.dispatch; | ||
var getState = _ref.getState; | ||
var dispatch = _ref.dispatch, | ||
getState = _ref.getState; | ||
return function (next) { | ||
@@ -10,0 +10,0 @@ return function (action) { |
{ | ||
"name": "redux-thunk", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "Thunk middleware for Redux.", | ||
"main": "lib/index.js", | ||
"jsnext:main": "es/index.js", | ||
"typings": "./index.d.ts", | ||
"files": [ | ||
@@ -11,3 +12,4 @@ "lib", | ||
"src", | ||
"dist" | ||
"dist", | ||
"index.d.ts" | ||
], | ||
@@ -71,5 +73,8 @@ "scripts": { | ||
"mocha": "^2.2.5", | ||
"redux": "^3.4.0", | ||
"rimraf": "^2.5.2", | ||
"typescript": "^1.8.10", | ||
"typescript-definition-tester": "0.0.4", | ||
"webpack": "^1.12.14" | ||
} | ||
} |
@@ -285,4 +285,39 @@ Redux Thunk | ||
## Injecting a Custom Argument | ||
Since 2.1.0, Redux Thunk supports injecting a custom argument using the `withExtraArgument` function: | ||
```js | ||
const store = createStore( | ||
reducer, | ||
applyMiddleware(thunk.withExtraArgument(api)) | ||
) | ||
// later | ||
function fetchUser(id) { | ||
return (dispatch, getState, api) => { | ||
// you can use api here | ||
} | ||
} | ||
``` | ||
To pass multiple things, just wrap them in a single object and use destructuring: | ||
```js | ||
const store = createStore( | ||
reducer, | ||
applyMiddleware(thunk.withExtraArgument({ api, whatever })) | ||
) | ||
// later | ||
function fetchUser(id) { | ||
return (dispatch, getState, { api, whatever }) => { | ||
// you can use api and something else here here | ||
} | ||
} | ||
``` | ||
## License | ||
MIT |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
17411
9
127
323
35
1