dva
Advanced tools
Comparing version 0.0.8 to 0.0.9
## `0.0.9` | ||
- app.start: Return react component so that can be rendered by ReactDOM | ||
## `0.0.8` | ||
@@ -3,0 +7,0 @@ |
@@ -11,2 +11,6 @@ 'use strict'; | ||
var _typeof2 = require('babel-runtime/helpers/typeof'); | ||
var _typeof3 = _interopRequireDefault(_typeof2); | ||
var _toConsumableArray2 = require('babel-runtime/helpers/toConsumableArray'); | ||
@@ -158,3 +162,3 @@ | ||
history = (0, _reactRouterRedux.syncHistoryWithStore)(opts.history || _reactRouter.hashHistory, store); | ||
} catch (e) {} | ||
} catch (e) {} /*eslint-disable no-empty*/ | ||
@@ -184,8 +188,16 @@ // Start saga. | ||
} else { | ||
var Routes = _routes; | ||
return _react2.default.createElement( | ||
_reactRedux.Provider, | ||
{ store: store }, | ||
_react2.default.createElement(Routes, { history: history }) | ||
); | ||
var _ret = function () { | ||
var Routes = _routes; | ||
return { | ||
v: function v() { | ||
return _react2.default.createElement( | ||
_reactRedux.Provider, | ||
{ store: store }, | ||
_react2.default.createElement(Routes, { history: history }) | ||
); | ||
} | ||
}; | ||
}(); | ||
if ((typeof _ret === 'undefined' ? 'undefined' : (0, _typeof3.default)(_ret)) === "object") return _ret.v; | ||
} | ||
@@ -192,0 +204,0 @@ |
@@ -52,3 +52,3 @@ 'use strict'; | ||
element: function element(n) { | ||
return (typeof n === 'undefined' ? 'undefined' : (0, _typeof3.default)(n)) === 'object' && n.nodeType && n.nodeName; | ||
return (typeof n === 'undefined' ? 'undefined' : (0, _typeof3.default)(n)) === 'object' && n !== null && n.nodeType && n.nodeName; | ||
}, | ||
@@ -65,7 +65,5 @@ array: Array.isArray, | ||
/** | ||
Print error in a useful way whether in a browser environment | ||
(with expandable error stack traces), or in a node.js environment | ||
(text-only log output) | ||
**/ | ||
// Print error in a useful way whether in a browser environment | ||
// (with expandable error stack traces), or in a node.js environment | ||
// (text-only log output) | ||
function log(level, message, error) { | ||
@@ -72,0 +70,0 @@ /*eslint-disable no-console*/ |
{ | ||
"name": "dva", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"description": "Front-end framework based on react, redux, react-redux, react-router and redux-saga, inspired by elm and choo.", | ||
@@ -24,7 +24,7 @@ "repository": { | ||
"scripts": { | ||
"test": "babel-node node_modules/.bin/babel-istanbul cover node_modules/.bin/_mocha --no-timeouts", | ||
"debug": "./node_modules/.bin/mocha --require babel-core/register --no-timeouts", | ||
"test": "nyc mocha --compilers js:babel-register --no-timeouts", | ||
"debug": "mocha --compilers js:babel-register --no-timeouts", | ||
"build": "rm -rf lib && babel src --out-dir lib --ignore __tests__", | ||
"lint": "eslint --ext .js src", | ||
"coveralls": "cat ./coverage/lcov.info | coveralls" | ||
"lint": "eslint --ext .js src test", | ||
"coveralls": "nyc report --reporter=text-lcov | coveralls" | ||
}, | ||
@@ -49,3 +49,2 @@ "dependencies": { | ||
"babel-eslint": "^6.0.4", | ||
"babel-istanbul": "^0.11.0", | ||
"babel-plugin-add-module-exports": "^0.2.1", | ||
@@ -56,2 +55,3 @@ "babel-plugin-transform-runtime": "^6.9.0", | ||
"babel-preset-stage-0": "~6.5.0", | ||
"babel-register": "^6.9.0", | ||
"babel-runtime": "^6.9.2", | ||
@@ -62,6 +62,8 @@ "browserify": "^13.0.1", | ||
"envify": "^3.4.1", | ||
"eslint": "^2.7.0", | ||
"eslint-config-airbnb": "^9.0.1", | ||
"eslint": "^3.0.1", | ||
"eslint-config-rackt": "^1.1.1", | ||
"eslint-plugin-react": "^5.2.2", | ||
"expect": "^1.20.2", | ||
"mocha": "^2.5.3", | ||
"nyc": "^7.0.0", | ||
"react": "^15.1.0", | ||
@@ -68,0 +70,0 @@ "react-dom": "^15.1.0", |
@@ -8,3 +8,3 @@ # dva | ||
Front-end framework based on react, redux, react-redux, react-router and redux-saga, inspired by elm and choo. | ||
Dis-frustrated lightweight front-end framework based on react, redux, react-router and redux-saga. | ||
@@ -11,0 +11,0 @@ ---- |
@@ -14,3 +14,3 @@ import React from 'react'; | ||
function dva(opts = {}) { | ||
const onError = opts.onError || function(err) { | ||
const onError = opts.onError || function (err) { | ||
throw new Error(err); | ||
@@ -31,3 +31,3 @@ }; | ||
start, | ||
store: null, | ||
store: null | ||
}; | ||
@@ -66,7 +66,7 @@ return app; | ||
let reducers = { | ||
routing, | ||
routing | ||
}; | ||
_models.forEach(model => { | ||
if (is.array(model.reducers)) { | ||
const [_reducers, enhancer] = model.reducers; | ||
const [ _reducers, enhancer ] = model.reducers; | ||
reducers[model.namespace] = enhancer(handleActions(_reducers || {}, model.state)); | ||
@@ -83,3 +83,3 @@ } else { | ||
check(opts.reducers, optReducers => { | ||
for (var k in optReducers) { | ||
for (let k in optReducers) { | ||
if (k in reducers) return false; | ||
@@ -94,7 +94,7 @@ } | ||
if (is.notUndef(opts.middlewares)) { | ||
check(opts.middlewares, is.array, 'Middlewares must be array.') | ||
check(opts.middlewares, is.array, 'Middlewares must be array.'); | ||
} | ||
const sagaMiddleware = createSagaMiddleware(); | ||
const enhancer = compose( | ||
applyMiddleware.apply(null, [sagaMiddleware, ...(opts.middlewares || [])]), | ||
applyMiddleware.apply(null, [ sagaMiddleware, ...(opts.middlewares || []) ]), | ||
window.devToolsExtension ? window.devToolsExtension() : f => f | ||
@@ -112,3 +112,3 @@ ); | ||
history = syncHistoryWithStore(opts.history || hashHistory, store); | ||
} catch (e) {} | ||
} catch (e) { /*eslint-disable no-empty*/ } | ||
@@ -137,5 +137,7 @@ // Start saga. | ||
const Routes = _routes; | ||
return <Provider store={store}> | ||
<Routes history={history} /> | ||
</Provider>; | ||
return () => ( | ||
<Provider store={store}> | ||
<Routes history={history} /> | ||
</Provider> | ||
); | ||
} | ||
@@ -147,3 +149,3 @@ | ||
if (Array.isArray(saga)) { | ||
[_saga, opts] = saga; | ||
[ _saga, opts ] = saga; | ||
opts = opts || {}; | ||
@@ -177,3 +179,3 @@ check(opts.type, is.sagaType, 'Type must be takeEvery, takeLatest or watcher'); | ||
function* rootSaga() { | ||
for (var k in sagas) { | ||
for (let k in sagas) { | ||
if (sagas.hasOwnProperty(k)) { | ||
@@ -180,0 +182,0 @@ const watcher = getWatcher(k, sagas[k]); |
@@ -22,14 +22,12 @@ import isPlainObject from 'is-plain-object'; | ||
number : n => typeof n === 'number', | ||
element : n => typeof n === 'object' && n.nodeType && n.nodeName, | ||
element : n => typeof n === 'object' && n !== null && n.nodeType && n.nodeName, | ||
array : Array.isArray, | ||
object : isPlainObject, | ||
jsx : v => v && v.$$typeof && v.$$typeof.toString() === 'Symbol(react.element)', | ||
sagaType : v => v === 'takeEvery' || v === 'takeLatest' || v === 'watcher', | ||
sagaType : v => v === 'takeEvery' || v === 'takeLatest' || v === 'watcher' | ||
}; | ||
/** | ||
Print error in a useful way whether in a browser environment | ||
(with expandable error stack traces), or in a node.js environment | ||
(text-only log output) | ||
**/ | ||
// Print error in a useful way whether in a browser environment | ||
// (with expandable error stack traces), or in a node.js environment | ||
// (text-only log output) | ||
export function log(level, message, error) { | ||
@@ -36,0 +34,0 @@ /*eslint-disable no-console*/ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
1049403
16659
22