Skip to content

Commit f997c0d

Browse files
committed
Initial commit.
0 parents  commit f997c0d

17 files changed

+938
-0
lines changed

.babelrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"stage": 0
3+
}

.editorconfig

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
src/utils/TimeTravel.js

.eslintrc

+184
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
{
2+
"env": {
3+
"node": true,
4+
"browser": true,
5+
"es6": true
6+
},
7+
"parser": "babel-eslint",
8+
"ecmaFeatures": {
9+
"modules": true,
10+
"jsx": true
11+
},
12+
"plugins": [
13+
"react"
14+
],
15+
"rules": {
16+
/* airbnb javascript style guide rules */
17+
"strict": [2, "never"],
18+
// es6
19+
"no-var": 0,
20+
// variables
21+
"no-shadow": 2,
22+
"no-shadow-restricted-names": 2,
23+
"no-unused-vars": [2, {
24+
"vars": "local",
25+
"args": "after-used"
26+
}],
27+
"no-use-before-define": 2,
28+
// possible errors
29+
"comma-dangle": [0, "always"],
30+
"no-cond-assign": [2, "always"],
31+
"no-debugger": 1,
32+
"no-alert": 1,
33+
"no-constant-condition": 1,
34+
"no-dupe-keys": 2,
35+
"no-duplicate-case": 2,
36+
"no-empty": 2,
37+
"no-ex-assign": 2,
38+
"no-extra-boolean-cast": 0,
39+
"no-extra-semi": 2,
40+
"no-func-assign": 2,
41+
"no-inner-declarations": 2,
42+
"no-invalid-regexp": 2,
43+
"no-irregular-whitespace": 2,
44+
"no-obj-calls": 2,
45+
"no-reserved-keys": 2,
46+
"no-sparse-arrays": 2,
47+
"no-unreachable": 2,
48+
"use-isnan": 2,
49+
"block-scoped-var": 2,
50+
// best practices
51+
"consistent-return": 2,
52+
"curly": [2, "multi-line"],
53+
"default-case": 2,
54+
"dot-notation": [2, {
55+
"allowKeywords": true
56+
}],
57+
"eqeqeq": 2,
58+
"guard-for-in": 2,
59+
"no-caller": 2,
60+
"no-eq-null": 0,
61+
"no-eval": 2,
62+
"no-extend-native": 2,
63+
"no-extra-bind": 2,
64+
"no-fallthrough": 2,
65+
"no-floating-decimal": 2,
66+
"no-implied-eval": 2,
67+
"no-lone-blocks": 2,
68+
"no-loop-func": 2,
69+
"no-multi-str": 2,
70+
"no-native-reassign": 2,
71+
"no-new": 2,
72+
"no-new-func": 2,
73+
"no-new-wrappers": 2,
74+
"no-octal": 2,
75+
"no-octal-escape": 2,
76+
"no-param-reassign": 2,
77+
"no-proto": 2,
78+
"no-redeclare": 2,
79+
"no-return-assign": 2,
80+
"no-script-url": 2,
81+
"no-self-compare": 2,
82+
"no-sequences": 2,
83+
"no-throw-literal": 2,
84+
"no-with": 2,
85+
"radix": 2,
86+
"vars-on-top": 2,
87+
"wrap-iife": [2, "any"],
88+
"yoda": 2,
89+
// style
90+
"indent": [2, 2],
91+
"brace-style": [2,
92+
"1tbs", {
93+
"allowSingleLine": true
94+
}],
95+
"quotes": [
96+
2, "single", "avoid-escape"
97+
],
98+
"camelcase": [2, {
99+
"properties": "never"
100+
}],
101+
"comma-spacing": [2, {
102+
"before": false,
103+
"after": true
104+
}],
105+
"comma-style": [2, "last"],
106+
"eol-last": 2,
107+
"key-spacing": [2, {
108+
"beforeColon": false,
109+
"afterColon": true
110+
}],
111+
"new-cap": [2, {
112+
"newIsCap": true
113+
}],
114+
"no-multiple-empty-lines": [2, {
115+
"max": 2
116+
}],
117+
"no-nested-ternary": 2,
118+
"no-new-object": 2,
119+
"no-spaced-func": 2,
120+
"no-trailing-spaces": 2,
121+
"no-wrap-func": 2,
122+
"no-underscore-dangle": 0,
123+
"one-var": [2, "never"],
124+
"padded-blocks": [2, "never"],
125+
"semi-spacing": [2, {
126+
"before": false,
127+
"after": true
128+
}],
129+
"space-after-keywords": 2,
130+
"space-before-blocks": 2,
131+
"space-infix-ops": 2,
132+
"space-return-throw-case": 2,
133+
"spaced-line-comment": 2,
134+
135+
/* custom rules */
136+
"no-console": 0,
137+
"space-before-function-paren": [2, {
138+
"named": "never",
139+
"anonymous": "always"
140+
}],
141+
"semi": [2, "never"],
142+
"func-names": 0,
143+
"consistent-this": [2, "this"],
144+
"func-style": [0, "expression"],
145+
"generator-star": [2, "end"],
146+
"max-nested-callbacks": [2, 3],
147+
"new-parens": 2,
148+
"no-array-constructor": 2,
149+
"no-else-return": 0,
150+
"no-inline-comments": 2,
151+
"no-lonely-if": 2,
152+
"no-mixed-spaces-and-tabs": 2,
153+
"no-multiple-empty-lines": [1, {
154+
"max": 2
155+
}],
156+
"no-ternary": 0,
157+
"operator-assignment": 0,
158+
"quote-props": [2, "as-needed"],
159+
"sort-vars": [0, {
160+
"ignoreCase": true
161+
}],
162+
"space-in-brackets": [0, "never",
163+
{
164+
"arraysInArrays": false,
165+
"arraysInObjects": false,
166+
"singleValue": false,
167+
"objectsInArrays": false,
168+
"objectsInObjects": false,
169+
"propertyName": false
170+
}
171+
],
172+
"space-in-parens": [2, "never"],
173+
"space-unary-ops": [2,
174+
{
175+
"words": true,
176+
"nonwords": false
177+
}
178+
],
179+
"wrap-regex": 2,
180+
181+
/* react rules */
182+
"react/jsx-uses-vars": 1
183+
}
184+
}

.gitignore

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
TODO
2+
coverage
3+
node_modules
4+
npm-debug.log
5+
test/browser/tests.js
6+
lib
7+
utils/*
8+
flux.js
9+
flux-build.js
10+
flux-build.min.js

.npmignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
TODO
2+
bower.json
3+
coverage
4+
examples
5+
npm-debug.log
6+
src
7+
test/browser/tests.js
8+
web

.travis.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
language: node_js
2+
script: npm run lint && npm run coverage
3+
after_script: cat ./coverage/lcov.info | coveralls
4+
node_js:
5+
- "0.10"
6+
- "0.12"
7+
- iojs-v1.8.1

README.md

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# connectToStores (for alt)
2+
3+
'Higher Order Component' for alt flux that controls the props of a wrapped
4+
component via stores.
5+
6+
**Alt** is an Isomorphic flux implementation.
7+
8+
Check out the [API Reference](http://alt.js.org/docs/) for full in-depth alt docs. For a high-level walk-through on flux, take a look at the [Getting Started](http://alt.js.org/guide/) guide.
9+
10+
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/goatslacker/alt?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
11+
12+
[![NPM version](https://badge.fury.io/js/alt.svg)](http://badge.fury.io/js/alt)
13+
[![Build Status](https://secure.travis-ci.org/goatslacker/alt.svg?branch=master)](http://travis-ci.org/goatslacker/alt)
14+
[![Coverage Status](https://img.shields.io/coveralls/goatslacker/alt.svg?style=flat)](https://coveralls.io/r/goatslacker/alt)
15+
[![Dependency Status](https://david-dm.org/goatslacker/alt.svg)](https://david-dm.org/goatslacker/alt)
16+
[![Download Count](https://img.shields.io/npm/dm/alt.svg?style=flat)](https://www.npmjs.com/package/alt)
17+
[![JS.ORG](https://img.shields.io/badge/js.org-alt-ffb400.svg?style=flat-square)](http://js.org)
18+
19+
## How to use
20+
21+
Expects the Component to have two static methods:
22+
- getStores(): Should return an array of stores.
23+
- getPropsFromStores(props): Should return the props from the stores.
24+
25+
**Using old React.createClass() style:**
26+
27+
```js
28+
const MyComponent = React.createClass({
29+
statics: {
30+
getStores(props) {
31+
return [myStore]
32+
},
33+
getPropsFromStores(props) {
34+
return myStore.getState()
35+
}
36+
},
37+
render() {
38+
// Use this.props like normal ...
39+
}
40+
})
41+
MyComponent = connectToStores(MyComponent)
42+
```
43+
44+
**Using ES6 Class:**
45+
46+
```js
47+
class MyComponent extends React.Component {
48+
static getStores(props) {
49+
return [myStore]
50+
}
51+
static getPropsFromStores(props) {
52+
return myStore.getState()
53+
}
54+
render() {
55+
// Use this.props like normal ...
56+
}
57+
}
58+
MyComponent = connectToStores(MyComponent)
59+
```
60+
61+
**Using ES7 Decorators (proposal, stage 0):**
62+
63+
```js
64+
@connectToStores
65+
class MyComponent extends React.Component {
66+
static getStores(props) {
67+
return [myStore]
68+
}
69+
static getPropsFromStores(props) {
70+
return myStore.getState()
71+
}
72+
render() {
73+
// Use this.props like normal ...
74+
}
75+
}
76+
```
77+
78+
A great explanation of the merits of higher order components can be found at
79+
http://bit.ly/1abPkrP
80+
81+
## Use as a component wrapper
82+
83+
[Hot-to here]
84+
85+
## License
86+
87+
[![MIT](https://img.shields.io/npm/l/alt.svg?style=flat)](http://josh.mit-license.org)

bower.json

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"name": "alt-connect-to-stores",
3+
"version": "0.0.1",
4+
"homepage": "https://github.com/altjs/connect-to-stores",
5+
"authors": [
6+
"Josh Perez <josh@goatslacker.com>",
7+
"Brian Link <cpsubrian@gmail.com>"
8+
],
9+
"description": "",
10+
"main": "dist/connect-to-stores.js",
11+
"devDependencies": {
12+
"babel": "^4.0.1",
13+
"coveralls": "^2.11.2",
14+
"istanbul": "^0.3.5",
15+
"mocha": "^2.1.0",
16+
"alt": "^0.17.1"
17+
},
18+
"keywords": [
19+
"alt",
20+
"es6",
21+
"flow",
22+
"flux",
23+
"react",
24+
"unidirectional"
25+
],
26+
"license": "MIT",
27+
"ignore": [
28+
"**/.*",
29+
"node_modules",
30+
"bower_components",
31+
"test",
32+
"tests",
33+
"examples",
34+
"src",
35+
"coverage-test.js",
36+
"coverage",
37+
"TODO"
38+
]
39+
}

dist.config.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
module.exports = {
2+
context: __dirname + '/src',
3+
entry: {
4+
'connectToStores': ['./connectToStores.js']
5+
},
6+
output: {
7+
path: __dirname + '/dist',
8+
filename: '[name].js',
9+
library: 'Alt',
10+
libraryTarget: 'umd'
11+
},
12+
module: {
13+
loaders: [{
14+
test: /\.js$/,
15+
loader: 'babel',
16+
exclude: /node_modules/
17+
}]
18+
},
19+
externals: {
20+
'react': 'react',
21+
'react/addons': 'react/addons',
22+
'alt': 'alt'
23+
}
24+
};

0 commit comments

Comments
 (0)