Socket
Socket
Sign inDemoInstall

redux-thunk

Package Overview
Dependencies
0
Maintainers
3
Versions
23
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.1.0 to 2.1.1

index.d.ts

4

dist/redux-thunk.js

@@ -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
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc