react-router-redux
Advanced tools
Comparing version 4.0.7 to 4.0.8
@@ -0,1 +1,5 @@ | ||
## [4.0.8](https://github.com/reactjs/react-router-redux/compare/v4.0.7...v4.0.8) | ||
- Don't run listeners synchronously with history 3 [`b2c2259`](https://github.com/reactjs/react-router-redux/commit/b2c2259c189cafad3e6e68eac7729e74f2bd56a9) | ||
## [4.0.7](https://github.com/reactjs/react-router-redux/compare/v4.0.6...v4.0.7) | ||
@@ -2,0 +6,0 @@ |
@@ -24,5 +24,5 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
/******/ var module = installedModules[moduleId] = { | ||
/******/ exports: {}, | ||
/******/ id: moduleId, | ||
/******/ loaded: false | ||
/******/ i: moduleId, | ||
/******/ l: false, | ||
/******/ exports: {} | ||
/******/ }; | ||
@@ -34,3 +34,3 @@ | ||
/******/ // Flag the module as loaded | ||
/******/ module.loaded = true; | ||
/******/ module.l = true; | ||
@@ -48,2 +48,28 @@ /******/ // Return the exports of the module | ||
/******/ // identity function for calling harmony imports with the correct context | ||
/******/ __webpack_require__.i = function(value) { return value; }; | ||
/******/ // define getter function for harmony exports | ||
/******/ __webpack_require__.d = function(exports, name, getter) { | ||
/******/ if(!__webpack_require__.o(exports, name)) { | ||
/******/ Object.defineProperty(exports, name, { | ||
/******/ configurable: false, | ||
/******/ enumerable: true, | ||
/******/ get: getter | ||
/******/ }); | ||
/******/ } | ||
/******/ }; | ||
/******/ // getDefaultExport function for compatibility with non-harmony modules | ||
/******/ __webpack_require__.n = function(module) { | ||
/******/ var getter = module && module.__esModule ? | ||
/******/ function getDefault() { return module['default']; } : | ||
/******/ function getModuleExports() { return module; }; | ||
/******/ __webpack_require__.d(getter, 'a', getter); | ||
/******/ return getter; | ||
/******/ }; | ||
/******/ // Object.prototype.hasOwnProperty.call | ||
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; | ||
/******/ // __webpack_public_path__ | ||
@@ -53,3 +79,3 @@ /******/ __webpack_require__.p = ""; | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(0); | ||
/******/ return __webpack_require__(__webpack_require__.s = 4); | ||
/******/ }) | ||
@@ -59,368 +85,374 @@ /************************************************************************/ | ||
/* 0 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/***/ (function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.routerMiddleware = exports.routerActions = exports.goForward = exports.goBack = exports.go = exports.replace = exports.push = exports.CALL_HISTORY_METHOD = exports.routerReducer = exports.LOCATION_CHANGE = exports.syncHistoryWithStore = undefined; | ||
var _reducer = __webpack_require__(2); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
/** | ||
* This action type will be dispatched by the history actions below. | ||
* If you're writing a middleware to watch for navigation events, be sure to | ||
* look for actions of this type. | ||
*/ | ||
var CALL_HISTORY_METHOD = exports.CALL_HISTORY_METHOD = '@@router/CALL_HISTORY_METHOD'; | ||
Object.defineProperty(exports, 'LOCATION_CHANGE', { | ||
enumerable: true, | ||
get: function get() { | ||
return _reducer.LOCATION_CHANGE; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'routerReducer', { | ||
enumerable: true, | ||
get: function get() { | ||
return _reducer.routerReducer; | ||
} | ||
}); | ||
function updateLocation(method) { | ||
return function () { | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
var _actions = __webpack_require__(1); | ||
return { | ||
type: CALL_HISTORY_METHOD, | ||
payload: { method: method, args: args } | ||
}; | ||
}; | ||
} | ||
Object.defineProperty(exports, 'CALL_HISTORY_METHOD', { | ||
enumerable: true, | ||
get: function get() { | ||
return _actions.CALL_HISTORY_METHOD; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'push', { | ||
enumerable: true, | ||
get: function get() { | ||
return _actions.push; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'replace', { | ||
enumerable: true, | ||
get: function get() { | ||
return _actions.replace; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'go', { | ||
enumerable: true, | ||
get: function get() { | ||
return _actions.go; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'goBack', { | ||
enumerable: true, | ||
get: function get() { | ||
return _actions.goBack; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'goForward', { | ||
enumerable: true, | ||
get: function get() { | ||
return _actions.goForward; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'routerActions', { | ||
enumerable: true, | ||
get: function get() { | ||
return _actions.routerActions; | ||
} | ||
}); | ||
/** | ||
* These actions correspond to the history API. | ||
* The associated routerMiddleware will capture these events before they get to | ||
* your reducer and reissue them as the matching function on your history. | ||
*/ | ||
var push = exports.push = updateLocation('push'); | ||
var replace = exports.replace = updateLocation('replace'); | ||
var go = exports.go = updateLocation('go'); | ||
var goBack = exports.goBack = updateLocation('goBack'); | ||
var goForward = exports.goForward = updateLocation('goForward'); | ||
var _sync = __webpack_require__(4); | ||
var routerActions = exports.routerActions = { push: push, replace: replace, go: go, goBack: goBack, goForward: goForward }; | ||
var _sync2 = _interopRequireDefault(_sync); | ||
/***/ }), | ||
/* 1 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var _middleware = __webpack_require__(3); | ||
"use strict"; | ||
var _middleware2 = _interopRequireDefault(_middleware); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.syncHistoryWithStore = _sync2['default']; | ||
exports.routerMiddleware = _middleware2['default']; | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
/***/ }, | ||
/* 1 */ | ||
/***/ function(module, exports) { | ||
exports.routerReducer = routerReducer; | ||
/** | ||
* This action type will be dispatched when your history | ||
* receives a location change. | ||
*/ | ||
var LOCATION_CHANGE = exports.LOCATION_CHANGE = '@@router/LOCATION_CHANGE'; | ||
'use strict'; | ||
var initialState = { | ||
locationBeforeTransitions: null | ||
}; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
/** | ||
* This action type will be dispatched by the history actions below. | ||
* If you're writing a middleware to watch for navigation events, be sure to | ||
* look for actions of this type. | ||
*/ | ||
var CALL_HISTORY_METHOD = exports.CALL_HISTORY_METHOD = '@@router/CALL_HISTORY_METHOD'; | ||
/** | ||
* This reducer will update the state with the most recent location history | ||
* has transitioned to. This may not be in sync with the router, particularly | ||
* if you have asynchronously-loaded routes, so reading from and relying on | ||
* this state is discouraged. | ||
*/ | ||
function routerReducer() { | ||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState; | ||
function updateLocation(method) { | ||
return function () { | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, | ||
type = _ref.type, | ||
payload = _ref.payload; | ||
return { | ||
type: CALL_HISTORY_METHOD, | ||
payload: { method: method, args: args } | ||
}; | ||
}; | ||
} | ||
if (type === LOCATION_CHANGE) { | ||
return _extends({}, state, { locationBeforeTransitions: payload }); | ||
} | ||
/** | ||
* These actions correspond to the history API. | ||
* The associated routerMiddleware will capture these events before they get to | ||
* your reducer and reissue them as the matching function on your history. | ||
*/ | ||
var push = exports.push = updateLocation('push'); | ||
var replace = exports.replace = updateLocation('replace'); | ||
var go = exports.go = updateLocation('go'); | ||
var goBack = exports.goBack = updateLocation('goBack'); | ||
var goForward = exports.goForward = updateLocation('goForward'); | ||
return state; | ||
} | ||
var routerActions = exports.routerActions = { push: push, replace: replace, go: go, goBack: goBack, goForward: goForward }; | ||
/***/ }, | ||
/***/ }), | ||
/* 2 */ | ||
/***/ function(module, exports) { | ||
/***/ (function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports['default'] = routerMiddleware; | ||
exports.routerReducer = routerReducer; | ||
/** | ||
* This action type will be dispatched when your history | ||
* receives a location change. | ||
*/ | ||
var LOCATION_CHANGE = exports.LOCATION_CHANGE = '@@router/LOCATION_CHANGE'; | ||
var _actions = __webpack_require__(0); | ||
var initialState = { | ||
locationBeforeTransitions: null | ||
}; | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
/** | ||
* This reducer will update the state with the most recent location history | ||
* has transitioned to. This may not be in sync with the router, particularly | ||
* if you have asynchronously-loaded routes, so reading from and relying on | ||
* this state is discouraged. | ||
*/ | ||
function routerReducer() { | ||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState; | ||
/** | ||
* 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. | ||
*/ | ||
function routerMiddleware(history) { | ||
return function () { | ||
return function (next) { | ||
return function (action) { | ||
if (action.type !== _actions.CALL_HISTORY_METHOD) { | ||
return next(action); | ||
} | ||
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, | ||
type = _ref.type, | ||
payload = _ref.payload; | ||
var _action$payload = action.payload, | ||
method = _action$payload.method, | ||
args = _action$payload.args; | ||
if (type === LOCATION_CHANGE) { | ||
return _extends({}, state, { locationBeforeTransitions: payload }); | ||
} | ||
history[method].apply(history, _toConsumableArray(args)); | ||
}; | ||
}; | ||
}; | ||
} | ||
return state; | ||
} | ||
/***/ }, | ||
/***/ }), | ||
/* 3 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/***/ (function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports['default'] = routerMiddleware; | ||
var _actions = __webpack_require__(1); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
/** | ||
* 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. | ||
*/ | ||
function routerMiddleware(history) { | ||
return function () { | ||
return function (next) { | ||
return function (action) { | ||
if (action.type !== _actions.CALL_HISTORY_METHOD) { | ||
return next(action); | ||
} | ||
exports['default'] = syncHistoryWithStore; | ||
var _action$payload = action.payload, | ||
method = _action$payload.method, | ||
args = _action$payload.args; | ||
var _reducer = __webpack_require__(1); | ||
history[method].apply(history, _toConsumableArray(args)); | ||
}; | ||
}; | ||
}; | ||
} | ||
var defaultSelectLocationState = function defaultSelectLocationState(state) { | ||
return state.routing; | ||
}; | ||
/***/ }, | ||
/* 4 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/** | ||
* This function synchronizes your history state with the Redux store. | ||
* Location changes flow from history to the store. An enhanced history is | ||
* returned with a listen method that responds to store updates for location. | ||
* | ||
* When this history is provided to the router, this means the location data | ||
* will flow like this: | ||
* history.push -> store.dispatch -> enhancedHistory.listen -> router | ||
* This ensures that when the store state changes due to a replay or other | ||
* event, the router will be updated appropriately and can transition to the | ||
* correct router state. | ||
*/ | ||
function syncHistoryWithStore(history, store) { | ||
var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}, | ||
_ref$selectLocationSt = _ref.selectLocationState, | ||
selectLocationState = _ref$selectLocationSt === undefined ? defaultSelectLocationState : _ref$selectLocationSt, | ||
_ref$adjustUrlOnRepla = _ref.adjustUrlOnReplay, | ||
adjustUrlOnReplay = _ref$adjustUrlOnRepla === undefined ? true : _ref$adjustUrlOnRepla; | ||
'use strict'; | ||
// Ensure that the reducer is mounted on the store and functioning properly. | ||
if (typeof selectLocationState(store.getState()) === 'undefined') { | ||
throw new Error('Expected the routing state to be available either as `state.routing` ' + 'or as the custom expression you can specify as `selectLocationState` ' + 'in the `syncHistoryWithStore()` options. ' + 'Ensure you have added the `routerReducer` to your store\'s ' + 'reducers via `combineReducers` or whatever method you use to isolate ' + 'your reducers.'); | ||
} | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var initialLocation = void 0; | ||
var isTimeTraveling = void 0; | ||
var unsubscribeFromStore = void 0; | ||
var unsubscribeFromHistory = void 0; | ||
var currentLocation = void 0; | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
// What does the store say about current location? | ||
var getLocationInStore = function getLocationInStore(useInitialIfEmpty) { | ||
var locationState = selectLocationState(store.getState()); | ||
return locationState.locationBeforeTransitions || (useInitialIfEmpty ? initialLocation : undefined); | ||
}; | ||
exports['default'] = syncHistoryWithStore; | ||
// Init initialLocation with potential location in store | ||
initialLocation = getLocationInStore(); | ||
var _reducer = __webpack_require__(2); | ||
// If the store is replayed, update the URL in the browser to match. | ||
if (adjustUrlOnReplay) { | ||
var handleStoreChange = function handleStoreChange() { | ||
var locationInStore = getLocationInStore(true); | ||
if (currentLocation === locationInStore || initialLocation === locationInStore) { | ||
return; | ||
} | ||
var defaultSelectLocationState = function defaultSelectLocationState(state) { | ||
return state.routing; | ||
}; | ||
// Update address bar to reflect store state | ||
isTimeTraveling = true; | ||
currentLocation = locationInStore; | ||
history.transitionTo(_extends({}, locationInStore, { | ||
action: 'PUSH' | ||
})); | ||
isTimeTraveling = false; | ||
}; | ||
/** | ||
* This function synchronizes your history state with the Redux store. | ||
* Location changes flow from history to the store. An enhanced history is | ||
* returned with a listen method that responds to store updates for location. | ||
* | ||
* When this history is provided to the router, this means the location data | ||
* will flow like this: | ||
* history.push -> store.dispatch -> enhancedHistory.listen -> router | ||
* This ensures that when the store state changes due to a replay or other | ||
* event, the router will be updated appropriately and can transition to the | ||
* correct router state. | ||
*/ | ||
function syncHistoryWithStore(history, store) { | ||
var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}, | ||
_ref$selectLocationSt = _ref.selectLocationState, | ||
selectLocationState = _ref$selectLocationSt === undefined ? defaultSelectLocationState : _ref$selectLocationSt, | ||
_ref$adjustUrlOnRepla = _ref.adjustUrlOnReplay, | ||
adjustUrlOnReplay = _ref$adjustUrlOnRepla === undefined ? true : _ref$adjustUrlOnRepla; | ||
unsubscribeFromStore = store.subscribe(handleStoreChange); | ||
handleStoreChange(); | ||
} | ||
// Ensure that the reducer is mounted on the store and functioning properly. | ||
if (typeof selectLocationState(store.getState()) === 'undefined') { | ||
throw new Error('Expected the routing state to be available either as `state.routing` ' + 'or as the custom expression you can specify as `selectLocationState` ' + 'in the `syncHistoryWithStore()` options. ' + 'Ensure you have added the `routerReducer` to your store\'s ' + 'reducers via `combineReducers` or whatever method you use to isolate ' + 'your reducers.'); | ||
} | ||
// Whenever location changes, dispatch an action to get it in the store | ||
var handleLocationChange = function handleLocationChange(location) { | ||
// ... unless we just caused that location change | ||
if (isTimeTraveling) { | ||
return; | ||
} | ||
var initialLocation = void 0; | ||
var isTimeTraveling = void 0; | ||
var unsubscribeFromStore = void 0; | ||
var unsubscribeFromHistory = void 0; | ||
var currentLocation = void 0; | ||
// Remember where we are | ||
currentLocation = location; | ||
// What does the store say about current location? | ||
var getLocationInStore = function getLocationInStore(useInitialIfEmpty) { | ||
var locationState = selectLocationState(store.getState()); | ||
return locationState.locationBeforeTransitions || (useInitialIfEmpty ? initialLocation : undefined); | ||
}; | ||
// Are we being called for the first time? | ||
if (!initialLocation) { | ||
// Remember as a fallback in case state is reset | ||
initialLocation = location; | ||
// Init initialLocation with potential location in store | ||
initialLocation = getLocationInStore(); | ||
// Respect persisted location, if any | ||
if (getLocationInStore()) { | ||
return; | ||
} | ||
} | ||
// If the store is replayed, update the URL in the browser to match. | ||
if (adjustUrlOnReplay) { | ||
var handleStoreChange = function handleStoreChange() { | ||
var locationInStore = getLocationInStore(true); | ||
if (currentLocation === locationInStore || initialLocation === locationInStore) { | ||
return; | ||
} | ||
// Tell the store to update by dispatching an action | ||
store.dispatch({ | ||
type: _reducer.LOCATION_CHANGE, | ||
payload: location | ||
}); | ||
}; | ||
unsubscribeFromHistory = history.listen(handleLocationChange); | ||
// Update address bar to reflect store state | ||
isTimeTraveling = true; | ||
currentLocation = locationInStore; | ||
history.transitionTo(_extends({}, locationInStore, { | ||
action: 'PUSH' | ||
})); | ||
isTimeTraveling = false; | ||
}; | ||
// History 3.x doesn't call listen synchronously, so fire the initial location change ourselves | ||
if (history.getCurrentLocation) { | ||
handleLocationChange(history.getCurrentLocation()); | ||
} | ||
unsubscribeFromStore = store.subscribe(handleStoreChange); | ||
handleStoreChange(); | ||
} | ||
// The enhanced history uses store as source of truth | ||
return _extends({}, history, { | ||
// The listeners are subscribed to the store instead of history | ||
listen: function listen(listener) { | ||
// Copy of last location. | ||
var lastPublishedLocation = getLocationInStore(true); | ||
// Whenever location changes, dispatch an action to get it in the store | ||
var handleLocationChange = function handleLocationChange(location) { | ||
// ... unless we just caused that location change | ||
if (isTimeTraveling) { | ||
return; | ||
} | ||
// Keep track of whether we unsubscribed, as Redux store | ||
// only applies changes in subscriptions on next dispatch | ||
var unsubscribed = false; | ||
var unsubscribeFromStore = store.subscribe(function () { | ||
var currentLocation = getLocationInStore(true); | ||
if (currentLocation === lastPublishedLocation) { | ||
return; | ||
} | ||
lastPublishedLocation = currentLocation; | ||
if (!unsubscribed) { | ||
listener(lastPublishedLocation); | ||
} | ||
}); | ||
// Remember where we are | ||
currentLocation = location; | ||
// History 2.x listeners expect a synchronous call. Make the first call to the | ||
// listener after subscribing to the store, in case the listener causes a | ||
// location change (e.g. when it redirects) | ||
if (!history.getCurrentLocation) { | ||
listener(lastPublishedLocation); | ||
} | ||
// Are we being called for the first time? | ||
if (!initialLocation) { | ||
// Remember as a fallback in case state is reset | ||
initialLocation = location; | ||
// Let user unsubscribe later | ||
return function () { | ||
unsubscribed = true; | ||
unsubscribeFromStore(); | ||
}; | ||
}, | ||
// Respect persisted location, if any | ||
if (getLocationInStore()) { | ||
return; | ||
} | ||
} | ||
// Tell the store to update by dispatching an action | ||
store.dispatch({ | ||
type: _reducer.LOCATION_CHANGE, | ||
payload: location | ||
}); | ||
}; | ||
unsubscribeFromHistory = history.listen(handleLocationChange); | ||
// It also provides a way to destroy internal listeners | ||
unsubscribe: function unsubscribe() { | ||
if (adjustUrlOnReplay) { | ||
unsubscribeFromStore(); | ||
} | ||
unsubscribeFromHistory(); | ||
} | ||
}); | ||
} | ||
// support history 3.x | ||
if (history.getCurrentLocation) { | ||
handleLocationChange(history.getCurrentLocation()); | ||
} | ||
/***/ }), | ||
/* 4 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
// The enhanced history uses store as source of truth | ||
return _extends({}, history, { | ||
// The listeners are subscribed to the store instead of history | ||
listen: function listen(listener) { | ||
// Copy of last location. | ||
var lastPublishedLocation = getLocationInStore(true); | ||
"use strict"; | ||
// Keep track of whether we unsubscribed, as Redux store | ||
// only applies changes in subscriptions on next dispatch | ||
var unsubscribed = false; | ||
var unsubscribeFromStore = store.subscribe(function () { | ||
var currentLocation = getLocationInStore(true); | ||
if (currentLocation === lastPublishedLocation) { | ||
return; | ||
} | ||
lastPublishedLocation = currentLocation; | ||
if (!unsubscribed) { | ||
listener(lastPublishedLocation); | ||
} | ||
}); | ||
// History listeners expect a synchronous call. Make the first call to the | ||
// listener after subscribing to the store, in case the listener causes a | ||
// location change (e.g. when it redirects) | ||
listener(lastPublishedLocation); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.routerMiddleware = exports.routerActions = exports.goForward = exports.goBack = exports.go = exports.replace = exports.push = exports.CALL_HISTORY_METHOD = exports.routerReducer = exports.LOCATION_CHANGE = exports.syncHistoryWithStore = undefined; | ||
// Let user unsubscribe later | ||
return function () { | ||
unsubscribed = true; | ||
unsubscribeFromStore(); | ||
}; | ||
}, | ||
var _reducer = __webpack_require__(1); | ||
Object.defineProperty(exports, 'LOCATION_CHANGE', { | ||
enumerable: true, | ||
get: function get() { | ||
return _reducer.LOCATION_CHANGE; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'routerReducer', { | ||
enumerable: true, | ||
get: function get() { | ||
return _reducer.routerReducer; | ||
} | ||
}); | ||
// It also provides a way to destroy internal listeners | ||
unsubscribe: function unsubscribe() { | ||
if (adjustUrlOnReplay) { | ||
unsubscribeFromStore(); | ||
} | ||
unsubscribeFromHistory(); | ||
} | ||
}); | ||
} | ||
var _actions = __webpack_require__(0); | ||
/***/ } | ||
/******/ ]) | ||
Object.defineProperty(exports, 'CALL_HISTORY_METHOD', { | ||
enumerable: true, | ||
get: function get() { | ||
return _actions.CALL_HISTORY_METHOD; | ||
} | ||
}); | ||
; | ||
Object.defineProperty(exports, 'push', { | ||
enumerable: true, | ||
get: function get() { | ||
return _actions.push; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'replace', { | ||
enumerable: true, | ||
get: function get() { | ||
return _actions.replace; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'go', { | ||
enumerable: true, | ||
get: function get() { | ||
return _actions.go; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'goBack', { | ||
enumerable: true, | ||
get: function get() { | ||
return _actions.goBack; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'goForward', { | ||
enumerable: true, | ||
get: function get() { | ||
return _actions.goForward; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'routerActions', { | ||
enumerable: true, | ||
get: function get() { | ||
return _actions.routerActions; | ||
} | ||
}); | ||
var _sync = __webpack_require__(3); | ||
var _sync2 = _interopRequireDefault(_sync); | ||
var _middleware = __webpack_require__(2); | ||
var _middleware2 = _interopRequireDefault(_middleware); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
exports.syncHistoryWithStore = _sync2['default']; | ||
exports.routerMiddleware = _middleware2['default']; | ||
/***/ }) | ||
/******/ ]); | ||
}); |
@@ -1,1 +0,1 @@ | ||
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports.ReactRouterRedux=r():e.ReactRouterRedux=r()}(this,function(){return function(e){function r(o){if(t[o])return t[o].exports;var n=t[o]={exports:{},id:o,loaded:!1};return e[o].call(n.exports,n,n.exports,r),n.loaded=!0,n.exports}var t={};return r.m=e,r.c=t,r.p="",r(0)}([function(e,r,t){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(r,"__esModule",{value:!0}),r.routerMiddleware=r.routerActions=r.goForward=r.goBack=r.go=r.replace=r.push=r.CALL_HISTORY_METHOD=r.routerReducer=r.LOCATION_CHANGE=r.syncHistoryWithStore=void 0;var n=t(2);Object.defineProperty(r,"LOCATION_CHANGE",{enumerable:!0,get:function(){return n.LOCATION_CHANGE}}),Object.defineProperty(r,"routerReducer",{enumerable:!0,get:function(){return n.routerReducer}});var u=t(1);Object.defineProperty(r,"CALL_HISTORY_METHOD",{enumerable:!0,get:function(){return u.CALL_HISTORY_METHOD}}),Object.defineProperty(r,"push",{enumerable:!0,get:function(){return u.push}}),Object.defineProperty(r,"replace",{enumerable:!0,get:function(){return u.replace}}),Object.defineProperty(r,"go",{enumerable:!0,get:function(){return u.go}}),Object.defineProperty(r,"goBack",{enumerable:!0,get:function(){return u.goBack}}),Object.defineProperty(r,"goForward",{enumerable:!0,get:function(){return u.goForward}}),Object.defineProperty(r,"routerActions",{enumerable:!0,get:function(){return u.routerActions}});var i=t(4),a=o(i),c=t(3),s=o(c);r.syncHistoryWithStore=a.default,r.routerMiddleware=s.default},function(e,r){"use strict";function t(e){return function(){for(var r=arguments.length,t=Array(r),n=0;n<r;n++)t[n]=arguments[n];return{type:o,payload:{method:e,args:t}}}}Object.defineProperty(r,"__esModule",{value:!0});var o=r.CALL_HISTORY_METHOD="@@router/CALL_HISTORY_METHOD",n=r.push=t("push"),u=r.replace=t("replace"),i=r.go=t("go"),a=r.goBack=t("goBack"),c=r.goForward=t("goForward");r.routerActions={push:n,replace:u,go:i,goBack:a,goForward:c}},function(e,r){"use strict";function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:u,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=r.type,i=r.payload;return t===n?o({},e,{locationBeforeTransitions:i}):e}Object.defineProperty(r,"__esModule",{value:!0});var o=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e};r.routerReducer=t;var n=r.LOCATION_CHANGE="@@router/LOCATION_CHANGE",u={locationBeforeTransitions:null}},function(e,r,t){"use strict";function o(e){if(Array.isArray(e)){for(var r=0,t=Array(e.length);r<e.length;r++)t[r]=e[r];return t}return Array.from(e)}function n(e){return function(){return function(r){return function(t){if(t.type!==u.CALL_HISTORY_METHOD)return r(t);var n=t.payload,i=n.method,a=n.args;e[i].apply(e,o(a))}}}}Object.defineProperty(r,"__esModule",{value:!0}),r.default=n;var u=t(1)},function(e,r,t){"use strict";function o(e,r){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=t.selectLocationState,a=void 0===o?i:o,c=t.adjustUrlOnReplay,s=void 0===c||c;if("undefined"==typeof a(r.getState()))throw new Error("Expected the routing state to be available either as `state.routing` or as the custom expression you can specify as `selectLocationState` in the `syncHistoryWithStore()` options. Ensure you have added the `routerReducer` to your store's reducers via `combineReducers` or whatever method you use to isolate your reducers.");var d=void 0,f=void 0,l=void 0,p=void 0,v=void 0,y=function(e){var t=a(r.getState());return t.locationBeforeTransitions||(e?d:void 0)};if(d=y(),s){var g=function(){var r=y(!0);v!==r&&d!==r&&(f=!0,v=r,e.transitionTo(n({},r,{action:"PUSH"})),f=!1)};l=r.subscribe(g),g()}var O=function(e){f||(v=e,!d&&(d=e,y())||r.dispatch({type:u.LOCATION_CHANGE,payload:e}))};return p=e.listen(O),e.getCurrentLocation&&O(e.getCurrentLocation()),n({},e,{listen:function(e){var t=y(!0),o=!1,n=r.subscribe(function(){var r=y(!0);r!==t&&(t=r,o||e(t))});return e(t),function(){o=!0,n()}},unsubscribe:function(){s&&l(),p()}})}Object.defineProperty(r,"__esModule",{value:!0});var n=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e};r.default=o;var u=t(2),i=function(e){return e.routing}}])}); | ||
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports.ReactRouterRedux=r():e.ReactRouterRedux=r()}(this,function(){return function(e){function r(o){if(t[o])return t[o].exports;var n=t[o]={i:o,l:!1,exports:{}};return e[o].call(n.exports,n,n.exports,r),n.l=!0,n.exports}var t={};return r.m=e,r.c=t,r.i=function(e){return e},r.d=function(e,t,o){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:o})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},r.p="",r(r.s=4)}([function(e,r,t){"use strict";function o(e){return function(){for(var r=arguments.length,t=Array(r),o=0;o<r;o++)t[o]=arguments[o];return{type:n,payload:{method:e,args:t}}}}Object.defineProperty(r,"__esModule",{value:!0});var n=r.CALL_HISTORY_METHOD="@@router/CALL_HISTORY_METHOD",u=r.push=o("push"),i=r.replace=o("replace"),a=r.go=o("go"),c=r.goBack=o("goBack"),f=r.goForward=o("goForward");r.routerActions={push:u,replace:i,go:a,goBack:c,goForward:f}},function(e,r,t){"use strict";function o(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=r.type,o=r.payload;return t===u?n({},e,{locationBeforeTransitions:o}):e}Object.defineProperty(r,"__esModule",{value:!0});var n=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e};r.routerReducer=o;var u=r.LOCATION_CHANGE="@@router/LOCATION_CHANGE",i={locationBeforeTransitions:null}},function(e,r,t){"use strict";function o(e){if(Array.isArray(e)){for(var r=0,t=Array(e.length);r<e.length;r++)t[r]=e[r];return t}return Array.from(e)}function n(e){return function(){return function(r){return function(t){if(t.type!==u.CALL_HISTORY_METHOD)return r(t);var n=t.payload,i=n.method,a=n.args;e[i].apply(e,o(a))}}}}Object.defineProperty(r,"__esModule",{value:!0}),r.default=n;var u=t(0)},function(e,r,t){"use strict";function o(e,r){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=t.selectLocationState,a=void 0===o?i:o,c=t.adjustUrlOnReplay,f=void 0===c||c;if("undefined"==typeof a(r.getState()))throw new Error("Expected the routing state to be available either as `state.routing` or as the custom expression you can specify as `selectLocationState` in the `syncHistoryWithStore()` options. Ensure you have added the `routerReducer` to your store's reducers via `combineReducers` or whatever method you use to isolate your reducers.");var s=void 0,d=void 0,l=void 0,p=void 0,y=void 0,v=function(e){var t=a(r.getState());return t.locationBeforeTransitions||(e?s:void 0)};if(s=v(),f){var g=function(){var r=v(!0);y!==r&&s!==r&&(d=!0,y=r,e.transitionTo(n({},r,{action:"PUSH"})),d=!1)};l=r.subscribe(g),g()}var O=function(e){d||(y=e,!s&&(s=e,v())||r.dispatch({type:u.LOCATION_CHANGE,payload:e}))};return p=e.listen(O),e.getCurrentLocation&&O(e.getCurrentLocation()),n({},e,{listen:function(t){var o=v(!0),n=!1,u=r.subscribe(function(){var e=v(!0);e!==o&&(o=e,n||t(o))});return e.getCurrentLocation||t(o),function(){n=!0,u()}},unsubscribe:function(){f&&l(),p()}})}Object.defineProperty(r,"__esModule",{value:!0});var n=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e};r.default=o;var u=t(1),i=function(e){return e.routing}},function(e,r,t){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(r,"__esModule",{value:!0}),r.routerMiddleware=r.routerActions=r.goForward=r.goBack=r.go=r.replace=r.push=r.CALL_HISTORY_METHOD=r.routerReducer=r.LOCATION_CHANGE=r.syncHistoryWithStore=void 0;var n=t(1);Object.defineProperty(r,"LOCATION_CHANGE",{enumerable:!0,get:function(){return n.LOCATION_CHANGE}}),Object.defineProperty(r,"routerReducer",{enumerable:!0,get:function(){return n.routerReducer}});var u=t(0);Object.defineProperty(r,"CALL_HISTORY_METHOD",{enumerable:!0,get:function(){return u.CALL_HISTORY_METHOD}}),Object.defineProperty(r,"push",{enumerable:!0,get:function(){return u.push}}),Object.defineProperty(r,"replace",{enumerable:!0,get:function(){return u.replace}}),Object.defineProperty(r,"go",{enumerable:!0,get:function(){return u.go}}),Object.defineProperty(r,"goBack",{enumerable:!0,get:function(){return u.goBack}}),Object.defineProperty(r,"goForward",{enumerable:!0,get:function(){return u.goForward}}),Object.defineProperty(r,"routerActions",{enumerable:!0,get:function(){return u.routerActions}});var i=t(3),a=o(i),c=t(2),f=o(c);r.syncHistoryWithStore=a.default,r.routerMiddleware=f.default}])}); |
@@ -106,3 +106,3 @@ 'use strict'; | ||
// support history 3.x | ||
// History 3.x doesn't call listen synchronously, so fire the initial location change ourselves | ||
if (history.getCurrentLocation) { | ||
@@ -133,6 +133,8 @@ handleLocationChange(history.getCurrentLocation()); | ||
// History listeners expect a synchronous call. Make the first call to the | ||
// History 2.x listeners expect a synchronous call. Make the first call to the | ||
// listener after subscribing to the store, in case the listener causes a | ||
// location change (e.g. when it redirects) | ||
listener(lastPublishedLocation); | ||
if (!history.getCurrentLocation) { | ||
listener(lastPublishedLocation); | ||
} | ||
@@ -139,0 +141,0 @@ // Let user unsubscribe later |
{ | ||
"name": "react-router-redux", | ||
"version": "4.0.7", | ||
"version": "4.0.8", | ||
"description": "Ruthlessly simple bindings to keep react-router and redux in sync", | ||
@@ -46,3 +46,3 @@ "main": "lib/index", | ||
"babel-core": "^6.7.4", | ||
"babel-eslint": "^4.1.6", | ||
"babel-eslint": "^7.1.1", | ||
"babel-loader": "^6.2.0", | ||
@@ -56,5 +56,8 @@ "babel-plugin-transform-es3-member-expression-literals": "^6.5.0", | ||
"babel-register": "^6.4.3", | ||
"eslint": "^1.10.3", | ||
"eslint-config-rackt": "^1.1.1", | ||
"eslint-plugin-react": "^3.15.0", | ||
"eslint": "^3.15.0", | ||
"eslint-config-react-app": "^0.5.0", | ||
"eslint-plugin-flowtype": "^2.29.2", | ||
"eslint-plugin-import": "^2.2.0", | ||
"eslint-plugin-jsx-a11y": "^4.0.0", | ||
"eslint-plugin-react": "^6.8.0", | ||
"expect": "^1.13.0", | ||
@@ -64,16 +67,13 @@ "history": "^3.0.0", | ||
"isparta-loader": "^2.0.0", | ||
"karma": "^0.13.3", | ||
"karma-chrome-launcher": "^0.2.0", | ||
"karma-coverage": "^0.5.3", | ||
"karma-firefox-launcher": "^0.1.7", | ||
"karma-ie-launcher": "^0.2.0", | ||
"karma-mocha": "^0.2.0", | ||
"karma-mocha-reporter": "^1.0.4", | ||
"karma-safari-launcher": "^0.1.1", | ||
"karma": "^1.4.1", | ||
"karma-coverage": "^1.1.1", | ||
"karma-firefox-launcher": "^1.0.0", | ||
"karma-mocha": "^1.3.0", | ||
"karma-mocha-reporter": "^2.2.2", | ||
"karma-sourcemap-loader": "^0.3.5", | ||
"karma-webpack": "^1.7.0", | ||
"mocha": "^2.3.4", | ||
"react": "^0.14.3", | ||
"react-dom": "^0.14.3", | ||
"react-redux": "^4.4.0", | ||
"karma-webpack": "^2.0.2", | ||
"mocha": "^3.2.0", | ||
"react": "^15.4.2", | ||
"react-dom": "^15.4.2", | ||
"react-redux": "^5.0.2", | ||
"react-router": "^3.0.0", | ||
@@ -84,4 +84,4 @@ "redux": "^3.0.4", | ||
"redux-devtools-log-monitor": "^1.0.1", | ||
"webpack": "^1.12.9" | ||
"webpack": "^2.2.1" | ||
} | ||
} |
@@ -9,3 +9,3 @@ # react-router-redux | ||
You're a smart person. You use [Redux](https://github.com/rackt/redux) to manage your application state. You use [React Router](https://github.com/reactjs/react-router) to do routing. All is good. | ||
You're a smart person. You use [Redux](https://github.com/reactjs/redux) to manage your application state. You use [React Router](https://github.com/reactjs/react-router) to do routing. All is good. | ||
@@ -94,3 +94,3 @@ But the two libraries don't coordinate. You want to do time travel with your application state, but React Router doesn't navigate between pages when you replay actions. It controls an important part of application state: the URL. | ||
React Router [provides route information via a route component's props](https://github.com/reactjs/react-router/blob/latest/docs/Introduction.md#getting-url-parameters). This makes it easy to access them from a container component. When using [react-redux](https://github.com/rackt/react-redux) to `connect()` your components to state, you can access the router's props from the [2nd argument of `mapStateToProps`](https://github.com/rackt/react-redux/blob/master/docs/api.md#connectmapstatetoprops-mapdispatchtoprops-mergeprops-options): | ||
React Router [provides route information via a route component's props](https://github.com/reactjs/react-router/blob/latest/docs/Introduction.md#getting-url-parameters). This makes it easy to access them from a container component. When using [react-redux](https://github.com/reactjs/react-redux) to `connect()` your components to state, you can access the router's props from the [2nd argument of `mapStateToProps`](https://github.com/reactjs/react-redux/blob/master/docs/api.md#connectmapstatetoprops-mapdispatchtoprops-mergeprops-options): | ||
@@ -97,0 +97,0 @@ ```js |
@@ -100,4 +100,4 @@ import { LOCATION_CHANGE } from './reducer' | ||
// support history 3.x | ||
if(history.getCurrentLocation) { | ||
// History 3.x doesn't call listen synchronously, so fire the initial location change ourselves | ||
if (history.getCurrentLocation) { | ||
handleLocationChange(history.getCurrentLocation()) | ||
@@ -128,6 +128,8 @@ } | ||
// History listeners expect a synchronous call. Make the first call to the | ||
// History 2.x listeners expect a synchronous call. Make the first call to the | ||
// listener after subscribing to the store, in case the listener causes a | ||
// location change (e.g. when it redirects) | ||
listener(lastPublishedLocation) | ||
if (!history.getCurrentLocation) { | ||
listener(lastPublishedLocation) | ||
} | ||
@@ -134,0 +136,0 @@ // Let user unsubscribe later |
Sorry, the diff of this file is not supported yet
59755
847