Skip to content

Commit f5f82b0

Browse files
committed
Merge pull request #36 from abelmokadem/master
Bower accessibility for ng-redux
2 parents 56a51e3 + 0afa062 commit f5f82b0

File tree

8 files changed

+61
-17
lines changed

8 files changed

+61
-17
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
node_modules
22
npm-debug.log
33
.DS_Store
4-
dist
54
lib
65
coverage
76
*.tgz

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,20 @@ For Angular 2 see [ng2-redux](https://github.com/wbuchwalter/ng2-redux).
2121

2222

2323
## Installation
24-
24+
#### npm
2525
```js
2626
npm install --save ng-redux
2727
```
28+
#### bower
29+
```js
30+
bower install --save ng-redux
31+
```
32+
33+
Add the following script tag to your html:
34+
35+
```html
36+
<script src="bower_components/ng-redux/dist/ng-redux.js"></script>
37+
```
2838

2939
## Quick Start
3040

bower.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "ng-redux",
3+
"version": "3.0.2",
4+
"homepage": "http://github.com/wbuchwalter/ng-redux",
5+
"authors": [
6+
"William Buchwalter <[email protected]> (http://github.com/wbuchwalter)"
7+
],
8+
"description": "Redux bindings for Angular.js",
9+
"main": "./dist/ng-redux.js",
10+
"moduleType": [],
11+
"keywords": [
12+
"angular",
13+
"redux"
14+
],
15+
"license": "MIT",
16+
"ignore": [
17+
"**/.*",
18+
"node_modules",
19+
"bower_components",
20+
"test",
21+
"tests"
22+
]
23+
}

dist/ng-redux.js

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

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"main": "./lib/index.js",
66
"scripts": {
77
"build": "rm -rf lib && `npm bin`/babel src --out-dir lib",
8+
"dist": "npm run build && ./node_modules/.bin/webpack --optimize-minimize lib/index.js dist/ng-redux.js",
89
"test": "mocha --compilers js:babel/register --recursive"
910
},
1011
"repository": {
@@ -31,7 +32,11 @@
3132
},
3233
"dependencies": {
3334
"invariant": "^2.1.0",
34-
"lodash": "^3.10.1",
35+
"lodash.assign": "^3.2.0",
36+
"lodash.isarray": "^3.0.4",
37+
"lodash.isfunction": "^3.0.6",
38+
"lodash.isobject": "^3.0.2",
39+
"lodash.isplainobject": "^3.2.0",
3540
"redux": "^3.0.0"
3641
}
3742
}

src/components/connector.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import shallowEqual from '../utils/shallowEqual';
22
import wrapActionCreators from '../utils/wrapActionCreators';
33
import invariant from 'invariant';
4-
import _ from 'lodash';
4+
5+
import isPlainObject from 'lodash.isplainobject';
6+
import isFunction from 'lodash.isfunction';
7+
import isObject from 'lodash.isobject';
8+
import assign from 'lodash.assign';
59

610
const defaultMapStateToTarget = () => ({});
711
const defaultMapDispatchToTarget = dispatch => ({dispatch});
@@ -11,17 +15,17 @@ export default function Connector(store) {
1115

1216
const finalMapStateToTarget = mapStateToTarget || defaultMapStateToTarget;
1317

14-
const finalMapDispatchToTarget = _.isPlainObject(mapDispatchToTarget) ?
18+
const finalMapDispatchToTarget = isPlainObject(mapDispatchToTarget) ?
1519
wrapActionCreators(mapDispatchToTarget) :
1620
mapDispatchToTarget || defaultMapDispatchToTarget;
1721

1822
invariant(
19-
_.isFunction(finalMapStateToTarget),
23+
isFunction(finalMapStateToTarget),
2024
'mapStateToTarget must be a Function. Instead received $s.', finalMapStateToTarget
2125
);
2226

2327
invariant(
24-
_.isPlainObject(finalMapDispatchToTarget) || _.isFunction(finalMapDispatchToTarget),
28+
isPlainObject(finalMapDispatchToTarget) || isFunction(finalMapDispatchToTarget),
2529
'mapDispatchToTarget must be a plain Object or a Function. Instead received $s.', finalMapDispatchToTarget
2630
);
2731

@@ -32,7 +36,7 @@ export default function Connector(store) {
3236
return (target) => {
3337

3438
invariant(
35-
_.isFunction(target) || _.isObject(target),
39+
isFunction(target) || isObject(target),
3640
'The target parameter passed to connect must be a Function or a object.'
3741
);
3842

@@ -53,18 +57,18 @@ export default function Connector(store) {
5357
}
5458

5559
function updateTarget(target, StateSlice, dispatch) {
56-
if(_.isFunction(target)) {
60+
if(isFunction(target)) {
5761
target(StateSlice, dispatch);
5862
} else {
59-
_.assign(target, StateSlice, dispatch);
63+
assign(target, StateSlice, dispatch);
6064
}
6165
}
6266

6367
function getStateSlice(state, mapStateToScope) {
6468
const slice = mapStateToScope(state);
6569

6670
invariant(
67-
_.isPlainObject(slice),
71+
isPlainObject(slice),
6872
'`mapStateToScope` must return an object. Instead received %s.',
6973
slice
7074
);

src/components/ngRedux.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ import Connector from './connector';
22
import invariant from 'invariant';
33
import {createStore, applyMiddleware, compose} from 'redux';
44
import digestMiddleware from './digestMiddleware';
5-
import _ from 'lodash';
5+
6+
import isArray from 'lodash.isarray';
7+
import isFunction from 'lodash.isfunction';
68

79
export default function ngReduxProvider() {
810
let _reducer = undefined;
@@ -11,13 +13,13 @@ export default function ngReduxProvider() {
1113

1214
this.createStoreWith = (reducer, middlewares, storeEnhancers) => {
1315
invariant(
14-
_.isFunction(reducer),
16+
isFunction(reducer),
1517
'The reducer parameter passed to createStoreWith must be a Function. Instead received %s.',
1618
typeof reducer
1719
);
1820

1921
invariant(
20-
!storeEnhancers || _.isArray(storeEnhancers),
22+
!storeEnhancers || isArray(storeEnhancers),
2123
'The storeEnhancers parameter passed to createStoreWith must be an Array. Instead received %s.',
2224
typeof storeEnhancers
2325
);

test/components/connector.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import expect from 'expect';
22
let sinon = require('sinon');
33
import { createStore } from 'redux';
44
import Connector from '../../src/components/connector';
5-
import _ from 'lodash';
5+
import isFunction from 'lodash.isfunction';
66

77
describe('Connector', () => {
88
let store;
@@ -70,8 +70,8 @@ describe('Connector', () => {
7070

7171
it('Should extend target (object) with actionCreators', () => {
7272
connect(() => ({}), { ac1: () => { }, ac2: () => { } })(targetObj);
73-
expect(_.isFunction(targetObj.ac1)).toBe(true);
74-
expect(_.isFunction(targetObj.ac2)).toBe(true);
73+
expect(isFunction(targetObj.ac1)).toBe(true);
74+
expect(isFunction(targetObj.ac2)).toBe(true);
7575
});
7676

7777
it('Should return an unsubscribing function', () => {

0 commit comments

Comments
 (0)