redux-token-api-middleware
Advanced tools
Comparing version 0.11.1 to 0.11.2
@@ -8,2 +8,3 @@ "use strict"; | ||
}); | ||
exports.createAsyncAction = createAsyncAction; | ||
exports.storeToken = storeToken; | ||
@@ -121,2 +122,8 @@ exports.retrieveToken = retrieveToken; | ||
var ASYNC_OPTIMIST_MAP = { | ||
START: 'BEGIN', | ||
COMPLETED: 'COMMIT', | ||
FAILED: 'REVERT' | ||
}; | ||
function createAsyncAction(type, step, payload) { | ||
@@ -138,2 +145,13 @@ var meta = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; | ||
var optimistId = meta.optimistId; | ||
if (optimistId !== undefined) { | ||
Object.assign(action, { | ||
optimist: { | ||
type: ASYNC_OPTIMIST_MAP[step], | ||
id: optimistId | ||
} | ||
}); | ||
} | ||
return action; | ||
@@ -140,0 +158,0 @@ } |
{ | ||
"name": "redux-token-api-middleware", | ||
"version": "0.11.1", | ||
"version": "0.11.2", | ||
"description": "Redux middleware for calling APIs with token-based auth", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -46,3 +46,9 @@ import startsWith from 'lodash.startswith'; | ||
function createAsyncAction(type, step, payload, meta = {}) { | ||
const ASYNC_OPTIMIST_MAP = { | ||
START: 'BEGIN', | ||
COMPLETED: 'COMMIT', | ||
FAILED: 'REVERT', | ||
}; | ||
export function createAsyncAction(type, step, payload, meta = {}) { | ||
let action = { | ||
@@ -61,2 +67,11 @@ type: `${type}_${step}`, | ||
} | ||
const { optimistId } = meta; | ||
if (optimistId !== undefined) { | ||
Object.assign(action, { | ||
optimist: { | ||
type: ASYNC_OPTIMIST_MAP[step], | ||
id: optimistId, | ||
} | ||
}); | ||
} | ||
return action; | ||
@@ -63,0 +78,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
40092
946