You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1.3 KiB
34 lines
1.3 KiB
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
|
|
|
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
|
|
|
|
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
|
|
|
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
|
|
|
|
import { CALL_HISTORY_METHOD } from './actions';
|
|
/**
|
|
* This middleware captures CALL_HISTORY_METHOD actions to redirect to the
|
|
* provided history object. This will prevent these actions from reaching your
|
|
* reducer or any middleware that comes after this one.
|
|
*/
|
|
|
|
var routerMiddleware = function routerMiddleware(history) {
|
|
return function (store) {
|
|
return function (next) {
|
|
return function (action) {
|
|
// eslint-disable-line no-unused-vars
|
|
if (action.type !== CALL_HISTORY_METHOD) {
|
|
return next(action);
|
|
}
|
|
|
|
var _action$payload = action.payload,
|
|
method = _action$payload.method,
|
|
args = _action$payload.args;
|
|
history[method].apply(history, _toConsumableArray(args));
|
|
};
|
|
};
|
|
};
|
|
};
|
|
|
|
export default routerMiddleware; |