Skip to content

Commit

Permalink
Merge eb71d99 into d7bbd66
Browse files Browse the repository at this point in the history
  • Loading branch information
sorrycc committed Apr 10, 2019
2 parents d7bbd66 + eb71d99 commit 3684919
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 101 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"doc:dev": "./website/node_modules/.bin/vuepress dev ./docs",
"doc:deploy": "cd ./website && npm run deploy && cd -",
"changelog": "lerna-changelog",
"test": "umi-test --coverage",
"test": "npm run debug -- --coverage",
"debug": "umi-test",
"coveralls": "cat ./coverage/lcov.info | coveralls",
"lint": "eslint --ext .js packages",
Expand All @@ -32,7 +32,7 @@
"react-testing-library": "^6.0.0",
"shelljs": "^0.8.1",
"umi-library": "^1.0.0",
"umi-test": "^1.0.0"
"umi-test": "^1.5.2"
},
"lint-staged": {
"*.js": [
Expand Down
21 changes: 8 additions & 13 deletions packages/dva-core/src/getSaga.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import invariant from 'invariant';
import warning from 'warning';
import {
effects as sagaEffects,
takeEvery,
takeLatest,
throttle,
} from 'redux-saga';
import { effects as sagaEffects } from 'redux-saga';
import { NAMESPACE_SEP } from './constants';
import prefixType from './prefixType';

Expand Down Expand Up @@ -37,14 +32,14 @@ function getWatcher(key, _effect, model, onError, onEffect) {
if (type === 'throttle') {
invariant(
opts.ms,
'app.start: opts.ms should be defined if type is throttle'
'app.start: opts.ms should be defined if type is throttle',
);
ms = opts.ms;
}
}
invariant(
['watcher', 'takeEvery', 'takeLatest', 'throttle'].indexOf(type) > -1,
'app.start: effect type should be takeEvery, takeLatest, throttle or watcher'
'app.start: effect type should be takeEvery, takeLatest, throttle or watcher',
);
}

Expand Down Expand Up @@ -76,15 +71,15 @@ function getWatcher(key, _effect, model, onError, onEffect) {
return sagaWithCatch;
case 'takeLatest':
return function*() {
yield takeLatest(key, sagaWithOnEffect);
yield sagaEffects.takeLatest(key, sagaWithOnEffect);
};
case 'throttle':
return function*() {
yield throttle(ms, key, sagaWithOnEffect);
yield sagaEffects.throttle(ms, key, sagaWithOnEffect);
};
default:
return function*() {
yield takeEvery(key, sagaWithOnEffect);
yield sagaEffects.takeEvery(key, sagaWithOnEffect);
};
}
}
Expand All @@ -96,7 +91,7 @@ function createEffects(model) {
type.indexOf(`${model.namespace}${NAMESPACE_SEP}`) !== 0,
`[${name}] ${type} should not be prefixed with namespace ${
model.namespace
}`
}`,
);
}
function put(action) {
Expand Down Expand Up @@ -132,7 +127,7 @@ function createEffects(model) {
return prefixType(t, model);
}
return t;
})
}),
);
} else {
return sagaEffects.take(type);
Expand Down
3 changes: 3 additions & 0 deletions packages/dva/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,6 @@ export function connect(
mergeProps?: Function,
options?: Object
): Function;

import * as routerRedux from 'connected-react-router';
export { routerRedux };
3 changes: 1 addition & 2 deletions packages/dva/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,14 @@
"@babel/runtime": "^7.0.0",
"@types/isomorphic-fetch": "^0.0.35",
"@types/react-router-dom": "^4.3.1",
"@types/react-router-redux": "^5.0.18",
"dva-core": "1.6.0-beta.1",
"global": "^4.3.2",
"history": "^4.7.2",
"invariant": "^2.2.4",
"isomorphic-fetch": "^2.2.1",
"react-redux": "^7.0.1",
"react-router-dom": "^4.3.1",
"react-router-redux": "5.0.0-alpha.9",
"connected-react-router": "^6.3.2",
"redux": "^4.0.1"
},
"peerDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/dva/router.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as routerRedux from 'react-router-redux';
import * as routerRedux from 'connected-react-router';

export * from 'react-router-dom';
export { routerRedux };
2 changes: 1 addition & 1 deletion packages/dva/router.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
module.exports = require('react-router-dom');
module.exports.routerRedux = require('react-router-redux');
module.exports.routerRedux = require('connected-react-router');
9 changes: 5 additions & 4 deletions packages/dva/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,23 @@ import document from 'global/document';
import { Provider, connect, connectAdvanced } from 'react-redux';
import { utils, create, saga } from 'dva-core';
import * as router from 'react-router-dom';
import * as routerRedux from 'react-router-redux';
import * as routerRedux from 'connected-react-router';

const { routerMiddleware, routerReducer: routing } = routerRedux;
const { ConnectedRouter, connectRouter, routerMiddleware } = routerRedux;
const { isFunction } = utils;

export default function(opts = {}) {
const history = opts.history || createHashHistory();
const createOpts = {
initialReducer: {
routing,
router: connectRouter(history),
},
setupMiddlewares(middlewares) {
return [routerMiddleware(history), ...middlewares];
},
setupApp(app) {
app._history = patchHistory(history);
// app._history = patchHistory(history);
},
};

Expand Down Expand Up @@ -110,7 +111,7 @@ function render(container, store, app, router) {
function patchHistory(history) {
const oldListen = history.listen;
history.listen = callback => {
callback(history.location);
callback(history.location, history.action);
return oldListen.call(history, callback);
};
return history;
Expand Down
43 changes: 21 additions & 22 deletions packages/dva/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,6 @@
"@types/react" "*"
"@types/react-router" "*"

"@types/react-router-redux@^5.0.18":
version "5.0.18"
resolved "https://registry.yarnpkg.com/@types/react-router-redux/-/react-router-redux-5.0.18.tgz#5f28d5f7387fa71e33f602ccf9269e1609d47b8b"
integrity sha512-5SI69Virpmo+5HXWXKIzSt5hsnV7TTidL3Ddmbi+PH1CIdi40wthJwjFoqiE+gRQANur5WhjEtfyPorJ4zymHA==
dependencies:
"@types/history" "*"
"@types/react" "*"
"@types/react-router" "*"
redux ">= 3.7.2"

"@types/react-router@*":
version "4.4.4"
resolved "https://registry.yarnpkg.com/@types/react-router/-/react-router-4.4.4.tgz#4dbd5588ea6024e0c04519bd8aabe74c0a2b77e5"
Expand All @@ -66,6 +56,14 @@
"@types/prop-types" "*"
csstype "^2.2.0"

connected-react-router@^6.3.2:
version "6.3.2"
resolved "https://registry.yarnpkg.com/connected-react-router/-/connected-react-router-6.3.2.tgz#8c90b77f1d7b783608cd50e4f69bf60e47265425"
integrity sha512-YxrAfMExl/OBsi+ojA4ywZeC7cmQ52MnZ4bhzqLhhjuOiXcQogC4kW0kodouXAXrXDovb2l3yEhDfpH99/wYcw==
dependencies:
immutable "^3.8.1"
seamless-immutable "^7.1.3"

csstype@^2.2.0:
version "2.6.3"
resolved "https://registry.yarnpkg.com/csstype/-/csstype-2.6.3.tgz#b701e5968245bf9b08d54ac83d00b624e622a9fa"
Expand Down Expand Up @@ -121,6 +119,11 @@ iconv-lite@~0.4.13:
dependencies:
safer-buffer ">= 2.1.2 < 3"

immutable@^3.8.1:
version "3.8.2"
resolved "https://registry.yarnpkg.com/immutable/-/immutable-3.8.2.tgz#c2439951455bb39913daf281376f1530e104adf3"
integrity sha1-wkOZUUVbs5kT2vKBN28VMOEErfM=

invariant@^2.2.1, invariant@^2.2.4:
version "2.2.4"
resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.4.tgz#610f3c92c9359ce1db616e538008d23ff35158e6"
Expand Down Expand Up @@ -190,7 +193,7 @@ process@~0.5.1:
resolved "https://registry.yarnpkg.com/process/-/process-0.5.2.tgz#1638d8a8e34c2f440a91db95ab9aeb677fc185cf"
integrity sha1-FjjYqONML0QKkduVq5rrZ3/Bhc8=

prop-types@^15.6.0, prop-types@^15.6.1, prop-types@^15.7.2:
prop-types@^15.6.1, prop-types@^15.7.2:
version "15.7.2"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.7.2.tgz#52c41e75b8c87e72b9d9360e0206b99dcbffa6c5"
integrity sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==
Expand Down Expand Up @@ -233,16 +236,7 @@ react-router-dom@^4.3.1:
react-router "^4.3.1"
warning "^4.0.1"

react-router-redux@5.0.0-alpha.9:
version "5.0.0-alpha.9"
resolved "https://registry.yarnpkg.com/react-router-redux/-/react-router-redux-5.0.0-alpha.9.tgz#825431516e0e6f1fd93b8807f6bd595e23ec3d10"
integrity sha512-euSgNIANnRXr4GydIuwA7RZCefrLQzIw5WdXspS8NPYbV+FxrKSS9MKG7U9vb6vsKHONnA4VxrVNWfnMUnUQAw==
dependencies:
history "^4.7.2"
prop-types "^15.6.0"
react-router "^4.2.0"

react-router@^4.2.0, react-router@^4.3.1:
react-router@^4.3.1:
version "4.3.1"
resolved "https://registry.yarnpkg.com/react-router/-/react-router-4.3.1.tgz#aada4aef14c809cb2e686b05cee4742234506c4e"
integrity sha512-yrvL8AogDh2X42Dt9iknk4wF4V8bWREPirFfS9gLU1huk6qK41sg7Z/1S81jjTrGHxa3B8R3J6xIkDAA6CVarg==
Expand All @@ -255,7 +249,7 @@ react-router@^4.2.0, react-router@^4.3.1:
prop-types "^15.6.1"
warning "^4.0.1"

"redux@>= 3.7.2", redux@^4.0.1:
redux@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/redux/-/redux-4.0.1.tgz#436cae6cc40fbe4727689d7c8fae44808f1bfef5"
integrity sha512-R7bAtSkk7nY6O/OYMVR9RiBI+XghjF9rlbl5806HJbQph0LJVHZrU5oaO4q70eUKiqMRqm4y07KLTlMZ2BlVmg==
Expand Down Expand Up @@ -283,6 +277,11 @@ resolve-pathname@^2.2.0:
resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a"
integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==

seamless-immutable@^7.1.3:
version "7.1.4"
resolved "https://registry.yarnpkg.com/seamless-immutable/-/seamless-immutable-7.1.4.tgz#6e9536def083ddc4dea0207d722e0e80d0f372f8"
integrity sha512-XiUO1QP4ki4E2PHegiGAlu6r82o5A+6tRh7IkGGTVg/h+UoeX4nFBeCGPOhb4CYjvkqsfm/TUtvOMYC1xmV30A==

symbol-observable@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.2.0.tgz#c22688aed4eab3cdc2dfeacbb561660560a00804"
Expand Down
Loading

0 comments on commit 3684919

Please sign in to comment.