Skip to content

Commit 8075440

Browse files
committed
Merge branch 'master' into rest-api-example
2 parents 3f31bdc + e4a48db commit 8075440

File tree

165 files changed

+43855
-4906
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

165 files changed

+43855
-4906
lines changed

.eslintrc

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
{
2+
"env": {
3+
"node": true,
4+
"browser": true,
5+
"amd": true
6+
},
7+
"ecmaFeatures": {
8+
"arrowFunctions": true,
9+
"classes": true,
10+
"defaultParams": true,
11+
"destructuring": true,
12+
"forOf": true,
13+
"objectLiteralShorthandMethods": true,
14+
"objectLiteralShorthandProperties": true,
15+
"spread": true,
16+
"superInFunctions": true
17+
},
18+
"globals": {
19+
"console": true,
20+
"beforeEach": true,
21+
"afterEach": true,
22+
"it": true,
23+
"describe": true,
24+
"module": true,
25+
"expect": true,
26+
"exports": true,
27+
"jasmine": true,
28+
"spyOn": true,
29+
"mocha": true,
30+
"mochaPhantomJS": true
31+
},
32+
"rules": {
33+
"comma-dangle": [1, "always-multiline"],
34+
"no-cond-assign": 1,
35+
"no-console": 1,
36+
"no-constant-condition": 1,
37+
"no-control-regex": 1,
38+
"no-debugger": 1,
39+
"no-dupe-args": 1,
40+
"no-dupe-keys": 1,
41+
"no-duplicate-case": 1,
42+
"no-empty": 1,
43+
"no-empty-class": 1,
44+
"no-ex-assign": 1,
45+
"no-extra-boolean-cast": 0,
46+
"no-extra-parens": 0,
47+
"no-extra-semi": 1,
48+
"no-func-assign": 1,
49+
"no-inner-declarations": 1,
50+
"no-invalid-regexp": 1,
51+
"no-irregular-whitespace": 1,
52+
"no-negated-in-lhs": 1,
53+
"no-obj-calls": 1,
54+
"no-regex-spaces": 1,
55+
"no-reserved-keys": 1,
56+
"no-sparse-arrays": 1,
57+
"no-unreachable": 1,
58+
"use-isnan": 1,
59+
"valid-jsdoc": 0,
60+
"valid-typeof": 1,
61+
"block-scoped-var": 1,
62+
"complexity": 0,
63+
"consistent-return": 0,
64+
"curly": 1,
65+
"default-case": 1,
66+
"dot-notation": 0,
67+
"dot-location": [1, "property"],
68+
"eqeqeq": 1,
69+
"guard-for-in": 1,
70+
"no-alert": 1,
71+
"no-caller": 1,
72+
"no-div-regex": 0,
73+
"no-else-return": 1,
74+
"no-empty-label": 1,
75+
"no-eq-null": 1,
76+
"no-eval": 1,
77+
"no-extend-native": 1,
78+
"no-extra-bind": 1,
79+
"no-fallthrough": 1,
80+
"no-floating-decimal": 1,
81+
"no-implied-eval": 1,
82+
"no-iterator": 1,
83+
"no-labels": 1,
84+
"no-lone-blocks": 1,
85+
"no-loop-func": 1,
86+
"no-multi-spaces": 1,
87+
"no-multi-str": 0,
88+
"no-native-reassign": 0,
89+
"no-new": 1,
90+
"no-new-func": 1,
91+
"no-new-wrappers": 1,
92+
"no-octal": 1,
93+
"no-octal-escape": 1,
94+
"no-param-reassign": 0,
95+
"no-process-env": 0,
96+
"no-proto": 1,
97+
"no-redeclare": 1,
98+
"no-return-assign": 1,
99+
"no-script-url": 1,
100+
"no-self-compare": 1,
101+
"no-sequences": 1,
102+
"no-throw-literal": 1,
103+
"no-unused-expressions": 1,
104+
"no-void": 1,
105+
"no-warning-comments": 0,
106+
"no-with": 0,
107+
"radix": 1,
108+
"vars-on-top": 0,
109+
"wrap-iife": [2, "any"],
110+
"yoda": [1, "never", {"exceptRange": true}],
111+
"strict": 0,
112+
"no-catch-shadow": 0,
113+
"no-delete-var": 1,
114+
"no-label-var": 0,
115+
"no-shadow": 0,
116+
"no-shadow-restricted-names": 1,
117+
"no-undef": 2,
118+
"no-undef-init": 1,
119+
"no-undefined": 0,
120+
"no-unused-vars": [1, {"vars": "local", "args": "none"}],
121+
"no-use-before-define": 0,
122+
"indent": [1, 2, {"indentSwitchCase": true}],
123+
"brace-style": [1, "1tbs", {"allowSingleLine": true}],
124+
"camelcase": 0,
125+
"comma-spacing": 1,
126+
"consistent-this": 0,
127+
"eol-last": 1,
128+
"func-names": 0,
129+
"func-style": 0,
130+
"key-spacing": [1, {
131+
"beforeColon": false,
132+
"afterColon": true
133+
}],
134+
"linebreak-style": 0,
135+
"max-nested-callbacks": 0,
136+
"new-cap": [1, {"newIsCap": true, "capIsNew": false}],
137+
"new-parens": 2,
138+
"newline-after-var": 0,
139+
"no-array-constructor": 1,
140+
"no-continue": 0,
141+
"no-inline-comments": 0,
142+
"no-lonely-if": 1,
143+
"no-mixed-spaces-and-tabs": 1,
144+
"no-multiple-empty-lines": [1, {"max": 2}],
145+
"no-nested-ternary": 1,
146+
"no-new-object": 1,
147+
"no-spaced-func": 1,
148+
"no-ternary": 0,
149+
"no-trailing-spaces": 1,
150+
"no-underscore-dangle": 0,
151+
"no-wrap-func": 1,
152+
"one-var": [1, "never"],
153+
"operator-assignment": 0,
154+
"operator-linebreak": 0,
155+
"padded-blocks": 0,
156+
"quote-props": 0,
157+
"quotes": [1, "single"],
158+
"semi": [1, "never"],
159+
"semi-spacing": [1, {"before": false, "after": true}],
160+
"sort-vars": 0,
161+
"space-after-keywords": [1, "always"],
162+
"space-before-blocks": 1,
163+
"space-before-function-paren": [1, "never"],
164+
"space-in-brackets": 0,
165+
"space-in-parens": [1, "never"],
166+
"space-infix-ops": 1,
167+
"space-return-throw-case": 1,
168+
"space-unary-ops": [1, {"words": true, "nonwords": false}],
169+
"spaced-line-comment": [1, "always", {"exceptions": ["-"]}],
170+
"wrap-regex": 0,
171+
"max-depth": 0,
172+
"max-len": 0,
173+
"max-params": 0,
174+
"max-statements": 0,
175+
"no-bitwise": 0,
176+
"no-plusplus": 0
177+
}
178+
}

CHANGELOG.md

Lines changed: 88 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,92 @@
1-
## 1.0.2
1+
## 1.1.0 (proposed)
22

3-
- **deprecated** `reactor.registerStore` will be deprecated in 1.1.x - use `reactor.registerStores` instead. Add deprecation warning.
4-
- **fixed** properly observe getters when passing `silent=true` for `registerStores` - this option no longer makes sense as it makes future observations unreliable.
5-
- **fixed** support `Utils.isFunction` in all browsers (#57)
6-
- **improvement** in Evaluator dont evaluate getter args twice when there is a stale value
3+
- **[NEW]** added `Reactor#serialize`, `Reactor#loadState`, `Store#serialize` and `Store#deserialize` methods
4+
- **[NEW]** added `Reactor#batch` to allow batch dispatches before notify observers
5+
- **[FIXED]** fix Evaluator locking if getter evaluation errors
76

8-
## 1.0.1
7+
### API Additions
98

10-
- **added** Expose createReactMixin functionality on Nuclear singleton
11-
- **fixed** Fix new Store() from throwing error when not passed a config object
9+
#### `Reactor#serialize()`
1210

13-
## 1.0.0
14-
- **Huge optimizations for `Reactor.evaluate` and `Reactor.observe`** - These values are now very efficiently memoized by leveraging that fact that getters are pure functions and are transforming immutable data. This means that complex transformations wont be reevaluated unless its direct dependencies or underlying state change.
15-
- **Built in support for React** - No need for the NuclearReactMixin, simply use `reactor.ReactMixin`
16-
- **breaking** `Reactor.get( ...getters, transformFn )` -> `Reactor.evaluate( getter )`
17-
- **breaking** `Reactor.getJS( ...getters, transformFn )` -> `Reactor.evaluateToJS( getter )`
18-
- **breaking** keypaths must always be arrays, no more support for 'foo.bar' style keypaths
19-
- **breaking** Getters are no longer a constructor, instead they are plain arrays of the form:
11+
Returns a plain javascript object representing the application state. By defualt this maps over all stores and returns `toJS(storeState)`.
12+
13+
```js
14+
reactor.loadState(reactor.serialize())
15+
```
16+
17+
#### `Reactor#loadState( state )`
18+
19+
Takes a plain javascript object and merges into the reactor state, using `store.deserialize`
20+
21+
This can be useful if you need to load data already on the page.
22+
23+
```js
24+
reactor.loadState({
25+
stringStore: 'bar',
26+
listStore: [4,5,6],
27+
})
28+
```
29+
30+
#### `Store#serialize`
31+
32+
Serialization method for the store's data, by default its implemented as `Nuclear.toJS' which converts ImmutableJS objects to plain javascript.
33+
This is overridable for your specific data needs.
34+
35+
```js
36+
// serializing an Immutable map while preserving numerical keys
37+
Nuclear.Store({
38+
// ...
39+
serialize(state) {
40+
if (!state) {
41+
return state;
42+
}
43+
return state.entrySeq().toJS()
44+
},
45+
// ...
46+
})
47+
```
48+
49+
#### `Store#deserialize`
50+
51+
Serialization method for the store's data, by default its implemented as `Nuclear.toImmutable' which converts plain javascript objects to ImmutableJS data structures.
52+
This is overridable for your specific data needs.
53+
54+
```js
55+
// deserializing an array of arrays [[1, 'one'], [2, 'two']] to an Immutable.Map
56+
Nuclear.Store({
57+
// ...
58+
deserialize(state) {
59+
return Immutable.Map(state)
60+
},
61+
// ...
62+
})
63+
```
64+
65+
## 1.0.5 (June 4, 2015)
66+
67+
- **[NEW]** Configured linting using [eslint](http://eslint.org/). Linting is now part of the [contributing process](https://github.com/optimizely/nuclear-js/blob/master/CONTRIBUTING.md). Eslint can be run using: `grunt eslint`
68+
- **[NEW]** Implemented new developer docs landing page. This website is still in beta. You can view it here: http://optimizely.github.io/nuclear-js/
69+
- **[FIXED]** Removed accidentally checked in node_modules directory.
70+
- **[FIXED]** Addressed all the lint warnings and errors in the codebase using the new rules in `.eslintrc`
71+
- **[FIXED]** Updated documentation.
72+
73+
## 1.0.2 (May 14, 2015)
74+
75+
- **[DEPRECATED]** `reactor.registerStore` will be deprecated in 1.1.x - use `reactor.registerStores` instead. Added deprecation warning.
76+
- **[FIXED]** Now properly observing getters when passing `silent=true` for `registerStores` - this option no longer makes sense as it makes future observations unreliable.
77+
- **[FIXED]** Support `Utils.isFunction` in all browsers. [#57](https://github.com/optimizely/nuclear-js/pull/57)
78+
- **[FIXED]** Evaluator now doesn't evaluate getter args twice when there is a stale value.
79+
80+
## 1.0.1 (April 27, 2015)
81+
82+
- **[NEW]** Expose `createReactMixin` functionality on Nuclear singleton.
83+
- **[FIXED]** Fix `new Store()` from throwing error when not passed a config object.
84+
85+
## 1.0.0 (April 25, 2015)
86+
87+
- **[NEW]** Built in support for React. No need for the `NuclearReactMixin`, simply use `reactor.ReactMixin`
88+
- **[BREAKING]** `Reactor.get( ...getters, transformFn )` -> `Reactor.evaluate( getter )`
89+
- **[BREAKING]** `Reactor.getJS( ...getters, transformFn )` -> `Reactor.evaluateToJS( getter )`
90+
- **[BREAKING]** Keypaths must always be arrays, no more support for 'foo.bar' style keypaths.
91+
- **[BREAKING]** Getters are no longer a constructor, instead they are plain arrays.
92+
- **[FIXED]** Huge optimizations for `Reactor.evaluate` and `Reactor.observe` - These values are now very efficiently memoized by leveraging that fact that getters are pure functions and are transforming immutable data. This means that complex transformations won't be reevaluated unless its direct dependencies or underlying state change.

CONTRIBUTING.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Welcome to NuclearJS!
44
If you are reading this, it probably means that you are interested in contributing to this awesome open source project.
55
To make the process of contributing more straightforward, we have prepared this guideline for you.
6+
To learn more about NuclearJS, check out our new [developer website!](http://optimizely.github.io/nuclear-js/)
67

78
## Development Setup
89

@@ -24,7 +25,9 @@ To run unit tests in PhantomJS + Coverage run: `grunt karma:coverage`
2425

2526
## Style Guide
2627

27-
Nothing special here. Just write good, clean JavaScript. Some general rules:
28+
Nothing special here. Just write good, clean JavaScript. We've made it easier to check your styling now by using [eslint.](http://eslint.org/) To get instant feedback on any styling violations, simply run: `grunt eslint`
29+
30+
Some general rules:
2831

2932
- 2 space indentation (no tabs).
3033
- Prefer `'` over `"`.
@@ -44,8 +47,8 @@ Nothing special here. Just write good, clean JavaScript. Some general rules:
4447
### Sending in a Pull Request Checklist
4548

4649
- [ ] Work only in the `src` folder and please DO NOT check in anything in the `dist` folder.
47-
- [ ] Follow the [Style Guide.](https://github.com/optimizely/nuclear-js/blob/master/CONTRIBUTING.md#style-guide)
50+
- [ ] Follow the [Style Guide.](https://github.com/optimizely/nuclear-js/blob/master/CONTRIBUTING.md#style-guide) Make sure that there are no lint errors or warnings after running: `grunt eslint`
4851
- [ ] Squash commits that are very small and redundant.
49-
- [ ] Make sure all tests pass.
52+
- [ ] Make sure all tests pass after running: `grunt test`
5053
- [ ] If you are implementing a new feature, be sure to add new tests for that feature.
5154
- [ ] Provide us with a detailed description of commits and changes.

Gruntfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = function (grunt) {
1+
module.exports = function(grunt) {
22
require('load-grunt-config')(grunt)
33
// load npm tasks
44
grunt.loadNpmTasks('grunt-karma')

NEXT.md

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

0 commit comments

Comments
 (0)