Skip to content

Commit 34665db

Browse files
authored
Merge pull request #9 from pofigizm/next
Next
2 parents b686436 + a30a185 commit 34665db

16 files changed

+355
-122
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
## 0.1.0 (2017-10-13)
1+
## 1.0.0
22
* release

example/package-lock.json

Lines changed: 33 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"react-loadable": "5.5.0",
99
"react-redux": "5.0.7",
1010
"react-scripts": "2.0.4",
11-
"redux-dynamic": "0.2.3"
11+
"redux-dynamic": "1.0.0"
1212
},
1313
"scripts": {
1414
"start": "react-scripts start",

example/src/App.test.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

example/src/index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { createInstance } from 'redux-dynamic'
99
import Loadable from 'react-loadable';
1010
import * as moduleOne from './module-one';
1111

12-
const dynamicStore = createInstance();
12+
const dynamicStore = createInstance({ key: 'base' });
1313
const store = dynamicStore.getStore();
1414

1515
// sync module
@@ -19,15 +19,15 @@ store.dispatch(moduleOne.actions.init());
1919

2020
// async module
2121
const ModuleTwoContainer = Loadable({
22-
loader: () => import('./module-two'),
23-
loading: () => <div> module-two loading... </div>,
24-
render: (loaded, props) => {
22+
loader: () => import('./module-two')
23+
.then((loaded) => {
2524
const { Container, ...moduleTwo} = loaded;
2625
dynamicStore.attach(moduleTwo);
2726
store.dispatch(moduleTwo.actions.init());
2827

29-
return <Container {...props} />;
30-
}
28+
return Container;
29+
}),
30+
loading: () => <div> module-two loading... </div>
3131
});
3232

3333
ReactDOM.render(

example/src/module-one/actions.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ const change = (payload = {}) => {
99
};
1010
};
1111

12-
export const init = (props) => async (dispatch, getState, { requestOneApi }) => {
12+
export const init = (props) => async (dispatch, getState, { moduleOne }) => {
1313
await dispatch(change(props));
14-
await requestOneApi();
14+
await moduleOne.requestApi();
1515

1616
return dispatch({ type: INIT });
1717
};

example/src/module-one/index.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,19 @@ import middleware from './middleware';
55
import reducer from './reducer';
66
import Container from './container';
77

8-
const reducers = {
9-
[constants.STORE_KEY]: reducer
8+
const thunk = {
9+
requestApi: () => new Promise(res => setTimeout(res, 2000))
1010
};
1111

12-
const thunkConfig = {
13-
requestOneApi: () => new Promise(res => setTimeout(res, 2000))
14-
};
12+
const key = constants.STORE_KEY;
1513

1614
export {
15+
key,
1716
actions,
1817
constants,
1918
middleware,
20-
reducers,
19+
reducer,
2120
selectors,
22-
thunkConfig,
21+
thunk,
2322
Container
2423
};

example/src/module-two/actions.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ const change = (payload = {}) => {
99
};
1010
};
1111

12-
export const init = (props) => async (dispatch, getState, { requestTwoApi }) => {
12+
export const init = (props) => async (dispatch, getState, { moduleTwo }) => {
1313
await dispatch(change(props));
14-
await requestTwoApi();
14+
await moduleTwo.requestApi();
1515

1616
return dispatch({ type: INIT });
1717
};

example/src/module-two/index.js

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,25 @@ import middleware from './middleware';
55
import reducer, { initialState as state } from './reducer';
66
import Container from './container';
77

8-
const reducers = {
9-
[constants.STORE_KEY]: reducer
10-
};
11-
12-
const initialState = {
13-
[constants.STORE_KEY]: {
14-
...state,
15-
someParam: true
16-
}
8+
const initial = {
9+
...state,
10+
someParam: true
1711
}
1812

19-
const thunkConfig = {
20-
requestTwoApi: () => new Promise(res => setTimeout(res, 2000))
13+
const thunk = {
14+
requestApi: () => new Promise(res => setTimeout(res, 2000))
2115
};
2216

17+
const key = constants.STORE_KEY
18+
2319
export {
24-
initialState,
20+
key,
21+
initial,
2522
actions,
2623
constants,
2724
middleware,
28-
reducers,
25+
reducer,
2926
selectors,
30-
thunkConfig,
27+
thunk,
3128
Container
3229
};

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "redux-dynamic",
3-
"version": "0.2.5",
3+
"version": "1.0.0",
44
"description": "Allow add or remove redux modules dynamically",
55
"main": "lib/index.js",
66
"scripts": {
@@ -33,7 +33,7 @@
3333
"babel-core": "6.26.3",
3434
"babel-jest": "23.6.0",
3535
"babel-preset-pofigizm": "1.0.0",
36-
"eslint": "5.7.0",
36+
"eslint": "5.14.1",
3737
"eslint-config-pofigizm": "1.0.0",
3838
"jest": "23.6.0"
3939
},

0 commit comments

Comments
 (0)