Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

Commit 3f469d1

Browse files
author
season
committed
dependencies
1 parent 1faf421 commit 3f469d1

File tree

8 files changed

+35
-28
lines changed

8 files changed

+35
-28
lines changed

README.md

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
- `Observable`: **可观察的数据流**,RxJS中的主要概念,也是`rx-hub`中的数据流,可以订阅。
3535

36-
## Reference directory structure
36+
## Reference directory structure
3737

3838
```
3939
|
@@ -58,7 +58,7 @@
5858

5959
## Getting started
6060

61-
> install
61+
> install
6262
6363
```sh
6464
# install rx-hub
@@ -67,11 +67,17 @@ npm install rx-hub -S
6767
# install rxjs, rx-hub have a peerDependencies of rxjs@5.x
6868
npm install rxjs@5.x -S
6969

70-
# import
70+
# 使用编译后的模块
7171
import {Hub, Store, logMiddleware} from 'data-hub';
72+
73+
# 或者使用es6模块:
74+
import Hub from 'data-hub/src/hub';
75+
import Store from 'data-hub/src/store';
76+
import logMiddleware from 'data-hub/src/middleware/log';
7277
```
7378

74-
> 定义`Converter`
79+
80+
> 定义`Converter`
7581
7682
每个`Converter`是一个函数,接受一个数据`payload`, 返回一个新的`Observable`对象。
7783

@@ -123,7 +129,7 @@ export let commit = ({mutation, payload}) => {
123129
};
124130
```
125131

126-
> 定义一个`Store`.
132+
> 定义一个`Store`.
127133
128134
`Store`用来长时间存储数据,类似现实生活中的`水池``Store`可以包含子模块`modules`, 每个子模块都是一个`Store`实例。
129135

@@ -213,16 +219,16 @@ index.html:
213219
<th>id</th>
214220
<th>用户名</th>
215221
<th>操作</th>
216-
</tr>
222+
</tr>
217223
</thead>
218224
<tbody>
219-
225+
220226
</tbody>
221227
</table>
222228
</div>
223229
```
224230

225-
index.js:
231+
index.js:
226232

227233
```js
228234
import hub from '../data/hubs/main';
@@ -260,7 +266,7 @@ function updateTable() {
260266
</tr>
261267
`;
262268
});
263-
269+
264270
// bind delete user
265271
$table.querySelector('tbody').innerHTML = $rows.join('');
266272
$table.querySelectorAll('tr > td > button').forEach(($btn, index) => {
@@ -346,7 +352,7 @@ $btn.addEventListener('click', () => {
346352

347353
[API文档](docs/zh-CN/api.md).
348354

349-
## run demo
355+
## run demo
350356

351357
> 已经为您提供了`原生js``vue``react`三个版本的demo,三个demo共用一份数据,你可以查看`demos`目录中的源码以了解更多细节。
352358
@@ -359,4 +365,4 @@ num run dev
359365

360366
- 原生js: http://localhost:8181/index.html
361367
- vue: http://localhost:8181/vue.html
362-
- react: http://localhost:8181/index.html
368+
- react: http://localhost:8181/index.html

dist/rx-hub.js

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

dist/rx-hub.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"name": "rx-hub",
3-
"version": "1.0.4",
3+
"version": "5.0.0",
44
"description": "> data hub",
55
"main": "dist/rx-hub.js",
66
"peerDependencies": {
7-
"rxjs": "^5.4.3"
7+
"rxjs": "^5.0.0"
88
},
99
"devDependencies": {
1010
"babel-core": "^6.25.0",

rollup.config.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ let external = [];
88
external = external.concat(Object.keys(pkg.dependencies || {}));
99
// external peer dependencies
1010
external = external.concat(Object.keys(pkg.peerDependencies || {}));
11+
external = external.concat(['rxjs/Observable', 'rxjs/Subject']);
1112

1213
let plugins = [
1314
babel({
@@ -26,12 +27,12 @@ export default {
2627
entry: 'index.js',
2728
plugins: plugins,
2829
external: external,
29-
sourceMap: true,
3030
dest: pkg.main,
3131
format: 'umd',
3232
moduleName: 'rx-hub',
3333
sourceMap: true,
3434
globals: {
35-
rxjs: 'Rx'
35+
'rxjs/Observable': 'Rx.Observable',
36+
'rxjs/Subject': 'Rx.Subject'
3637
}
3738
};

src/hub.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Observable} from 'rxjs';
1+
import {Observable} from 'rxjs/Observable';
22
import invariant from './util/invariant';
33

44
export default class Hub {

src/middleware/log.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Observable} from 'rxjs';
1+
import {Observable} from 'rxjs/Observable';
22

33
export default function logMiddleware({payload, pipeName, type}) {
44
let data = payload;
@@ -12,7 +12,7 @@ export default function logMiddleware({payload, pipeName, type}) {
1212
} catch(e) {
1313
//
1414
}
15-
15+
1616
console.log(`rx-hub log ~ pipe ${typeMsg} <${pipeName}>:`, data);
1717

1818
return Observable.of(payload);

src/store.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Subject} from 'rxjs';
1+
import {Subject} from 'rxjs/Subject';
22
import invariant from './util/invariant';
33

44
export default class Store {

0 commit comments

Comments
 (0)