Skip to content

Commit 004d6d1

Browse files
committed
rm ramda dependency
1 parent 91a72a2 commit 004d6d1

File tree

6 files changed

+90
-218
lines changed

6 files changed

+90
-218
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ npm install react-most --save
2626
then you can use `Most.default` and `Most.connect`
2727

2828
## What
29-
`react-most` is a simple, 100 LOC Higher Order Component for React. Its only dependencies are [most](https://github.com/cujojs/most), [most-subject](https://github.com/mostjs-community/subject), [ramda](https://github.com/Ramda/ramda), [React](https://github.com/facebook/react), and (optionally, if you prefered) [RxJS](https://github.com/Reactive-Extensions/RxJS).
29+
`react-most` is a simple, 100 LOC Higher Order Component for React. Its only dependencies are [most](https://github.com/cujojs/most), [most-subject](https://github.com/mostjs-community/subject), [React](https://github.com/facebook/react), and (optionally, if you prefered) [RxJS](https://github.com/Reactive-Extensions/RxJS).
3030

3131
Data flow in `react-most` is simple and unidirectional.
3232

lib/__tests__/react-most-test.jsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ import React from 'react';
22
import ReactDOM from 'react-dom';
33
import TestUtils from 'react-addons-test-utils';
44
import * as most from 'most';
5-
import {compose} from 'ramda';
5+
66
import Most, {connect} from '../react-most';
77
import {stateStreamOf, stateHistoryOf,
88
intentStreamOf, intentHistoryOf,
99
run, dispatch,
1010
Engine } from 'react-most-spec';
11+
const compose = f => g => x => g(f(x));
12+
1113
const CounterView = React.createClass({
1214
render(){
1315
return (
@@ -191,7 +193,7 @@ describe('react-most', () => {
191193
dec2: ()=>({type:'dec2'}),
192194
}
193195
})
194-
let counterWrapper21 = compose(counterWrapper2, counterWrapper)
196+
let counterWrapper21 = compose(counterWrapper2)(counterWrapper)
195197
const Counter2 = counterWrapper21(CounterView)
196198
it('counter add inc2, dec2', ()=>{
197199
let counterWrapper = TestUtils.renderIntoDocument(

lib/react-most.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ import React from 'react';
22
import initHistory from './history';
33
import { from } from 'most';
44
import mostEngine from './engine/most';
5-
import mergeAll from 'ramda/src/mergeAll';
6-
import pick from 'ramda/src/pick';
7-
import keys from 'ramda/src/keys';
85
// unfortunately React doesn't support symbol as context key yet, so let me just preteding using Symbol until react implement the Symbol version of Object.assign
96
export const INTENT_STREAM = '@@reactive-react/react-most.intentStream';
107
export const HISTORY_STREAM = '@@reactive-react/react-most.historyStream';
@@ -16,6 +13,13 @@ const CONTEXT_TYPE = {
1613
[MERGE_OBSERVE]: React.PropTypes.func,
1714
};
1815

16+
function pick(names, obj) {
17+
let result = {};
18+
for (let name of names) {
19+
if (obj[name]) result[name] = obj[name];
20+
}
21+
return result;
22+
}
1923
const h = React.createElement;
2024
export function connect(main, opts = {}) {
2125
return function(WrappedComponent) {
@@ -29,7 +33,7 @@ export function connect(main, opts = {}) {
2933
this
3034
);
3135
this.sink$ = sink$.concat(props.sink$ || []);
32-
this.actions = mergeAll([actions, props.actions]);
36+
this.actions = Object.assign({}, actions, props.actions);
3337
}
3438
render() {
3539
return h(
@@ -60,15 +64,16 @@ export function connect(main, opts = {}) {
6064
this
6165
);
6266
this.sink$ = sink$.concat(props.sink$ || []);
63-
this.actions = mergeAll([actions, props.actions]);
64-
let defaultKey = keys(WrappedComponent.defaultProps);
65-
this.state = mergeAll([
67+
this.actions = Object.assign({}, actions, props.actions);
68+
let defaultKey = Object.keys(WrappedComponent.defaultProps);
69+
this.state = Object.assign(
70+
{},
6671
WrappedComponent.defaultProps,
67-
pick(defaultKey, props),
68-
]);
72+
pick(defaultKey, props)
73+
);
6974
}
7075
componentWillReceiveProps(nextProps) {
71-
this.setState(state => pick(keys(state), nextProps));
76+
this.setState(state => pick(Object.keys(state), nextProps));
7277
}
7378
componentDidMount() {
7479
this.subscriptions = this.context[MERGE_OBSERVE](

node_modules/react-most

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: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,10 @@
2828
"dependencies": {
2929
"most": "^1.2.2",
3030
"most-subject": "^5.2.0",
31-
"ramda": "^0.23.0",
32-
"react": "^15.3.2",
33-
"react-most-spec": "0.2.3",
3431
"rxjs": "^5.0.0-rc.4"
3532
},
36-
"jest": {
37-
"moduleFileExtensions": [
38-
"js",
39-
"jsx",
40-
"es6"
41-
],
42-
"roots": [
43-
"lib"
44-
],
45-
"coverageDirectory": "./coverage/",
46-
"collectCoverage": true
33+
"peerDependencies": {
34+
"react": "^15.3.2"
4735
},
4836
"devDependencies": {
4937
"babel": "^6.1.18",
@@ -56,10 +44,23 @@
5644
"jest-cli": "^19.0.1",
5745
"lodash": "^4.0.0",
5846
"react-addons-test-utils": "^15.2.0",
47+
"react": "15.3.2",
5948
"react-dom": "^15.3.2",
60-
"react-most-spec": "^0.1.1",
49+
"react-most-spec": "^0.2.3",
6150
"redux": "^3.0.4"
6251
},
52+
"jest": {
53+
"moduleFileExtensions": [
54+
"js",
55+
"jsx",
56+
"es6"
57+
],
58+
"roots": [
59+
"lib"
60+
],
61+
"coverageDirectory": "./coverage/",
62+
"collectCoverage": true
63+
},
6364
"author": "Jichao Ouyang",
6465
"license": "MIT"
6566
}

0 commit comments

Comments
 (0)