Skip to content

Commit

Permalink
fix: route push problem with subscription in prod mode (#2234)
Browse files Browse the repository at this point in the history
* fix: route push problem with subscription in prod mode

* fix ci
  • Loading branch information
sorrycc authored Nov 1, 2019
1 parent 4d3ed5e commit 04eae82
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/dva-core/test/effects.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ describe('effects', () => {
effects: {
addDelay: [
function*({ payload }, { call, put }) {
yield call(delay, 100);
yield call(delay, 120);
yield put({ type: 'add', payload });
},
{ type: 'throttle', ms: 100 },
Expand Down
14 changes: 12 additions & 2 deletions packages/dva/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,22 @@ function render(container, store, app, router) {
function patchHistory(history) {
const oldListen = history.listen;
history.listen = callback => {
// TODO: refact this with modified ConnectedRouter
// Let ConnectedRouter to sync history to store first
// connected-react-router's version is locked since the check function may be broken
// min version of connected-react-router
// e.g.
// function (e, t) {
// var n = arguments.length > 2 && void 0 !== arguments[2] && arguments[2];
// r.inTimeTravelling ? r.inTimeTravelling = !1 : a(e, t, n)
// }
// ref: https://github.com/umijs/umi/issues/2693
const cbStr = callback.toString();
const isConnectedRouterHandler =
callback.name === 'handleLocationChange' &&
callback.toString().indexOf('onLocationChanged') > -1;
(callback.name === 'handleLocationChange' && cbStr.indexOf('onLocationChanged') > -1) ||
(cbStr.indexOf('.inTimeTravelling') > -1 &&
cbStr.indexOf('.inTimeTravelling') > -1 &&
cbStr.indexOf('arguments[2]') > -1);
callback(history.location, history.action);
return oldListen.call(history, (...args) => {
if (isConnectedRouterHandler) {
Expand Down

0 comments on commit 04eae82

Please sign in to comment.