redux-token-api-middleware
Advanced tools
Comparing version 0.8.8 to 0.8.9
@@ -89,8 +89,8 @@ 'use strict'; | ||
function createAsyncAction(type, step, payload) { | ||
var meta = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; | ||
var action = { | ||
type: type + '_' + step, | ||
payload: payload, | ||
meta: { | ||
asyncStep: step | ||
} | ||
meta: Object.assign(meta, { asyncStep: step }) | ||
}; | ||
@@ -109,4 +109,4 @@ if (payload && payload instanceof Error) { | ||
function createCompletionAction(type, payload) { | ||
return createAsyncAction(type, 'COMPLETED', payload); | ||
function createCompletionAction(type, payload, meta) { | ||
return createAsyncAction(type, 'COMPLETED', payload, meta); | ||
} | ||
@@ -207,3 +207,3 @@ | ||
value: function completeApiRequest(type, finalResponse) { | ||
this.dispatch(createCompletionAction(type, finalResponse)); | ||
this.dispatch(createCompletionAction(type, finalResponse, this.meta)); | ||
return finalResponse; | ||
@@ -210,0 +210,0 @@ } |
{ | ||
"name": "redux-token-api-middleware", | ||
"version": "0.8.8", | ||
"version": "0.8.9", | ||
"description": "Redux middleware for calling APIs with token-based auth", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -38,9 +38,10 @@ import startsWith from 'lodash.startswith'; | ||
function createAsyncAction(type, step, payload) { | ||
function createAsyncAction(type, step, payload, meta = {}) { | ||
let action = { | ||
type: `${type}_${step}`, | ||
payload: payload, | ||
meta: { | ||
asyncStep: step | ||
} | ||
meta: Object.assign( | ||
meta, | ||
{ asyncStep: step }, | ||
) | ||
}; | ||
@@ -59,4 +60,4 @@ if (payload && payload instanceof Error) { | ||
function createCompletionAction(type, payload) { | ||
return createAsyncAction(type, 'COMPLETED', payload); | ||
function createCompletionAction(type, payload, meta) { | ||
return createAsyncAction(type, 'COMPLETED', payload, meta); | ||
} | ||
@@ -168,3 +169,3 @@ | ||
this.dispatch(createCompletionAction( | ||
type, finalResponse | ||
type, finalResponse, this.meta, | ||
)); | ||
@@ -171,0 +172,0 @@ return finalResponse; |
250619