Skip to content

Commit f979b20

Browse files
committedNov 3, 2015
Merge branch 'master' into lyonlai-group-by-getter
2 parents 22bedfb + 77ced5e commit f979b20

9 files changed

+1306
-849
lines changed
 

‎CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## 1.2.0 (November 1, 2015)
2+
3+
- **[NEW]** Exposed new API methods: `batchStart` and `batchStop`.
4+
- **[NEW]** Changed the transpiler to Babel.
5+
- **[FIXED]** Completely refactored `Reactor`, `Evaluator` and `ChangeObserver`.
6+
- **[FIXED]** Fixed all issues related to hash code collisions.
7+
- **[FIXED]** Refactored how change observation works to be much more efficient.
8+
19
## 1.1.2 (October 5, 2015)
210

311
- **[FIXED]** Fix for observer iteration when removed during notify. [Issue #151](https://github.com/optimizely/nuclear-js/issues/151)

‎bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nuclear-js",
3-
"version": "1.1.2",
3+
"version": "1.2.0",
44
"homepage": "https://github.com/optimizely/nuclear-js",
55
"authors": [
66
"Jordan Garcia"

‎dist/nuclear.js

+1,247-842
Large diffs are not rendered by default.

‎dist/nuclear.min.js

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nuclear-js",
3-
"version": "1.1.2",
3+
"version": "1.2.0",
44
"description": "Immutable, reactive Flux architecture. UI Agnostic.",
55
"main": "dist/nuclear.js",
66
"scripts": {

‎src/console-polyfill.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
try {
2+
if (!(window.console && console.log)) {
3+
console = {
4+
log: function(){},
5+
debug: function(){},
6+
info: function(){},
7+
warn: function(){},
8+
error: function(){}
9+
};
10+
}
11+
} catch(e) {}

‎src/main.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import './console-polyfill'
12
import Store from './store'
23
import Reactor from './reactor'
34
import Immutable from 'immutable'

‎tests/reactor-tests.js

+32
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,28 @@ describe('Reactor', () => {
482482
expect(mockFn1.calls.count()).toEqual(2)
483483
expect(mockFn2.calls.count()).toEqual(1)
484484
})
485+
it('should allow a notify() after an unobserve during a handler', () => {
486+
var mockFn1 = jasmine.createSpy()
487+
var mockFn2 = jasmine.createSpy()
488+
var unwatchFn2
489+
var unwatchFn1 = reactor.observe(subtotalGetter, (val) => {
490+
console.log('hanlder1', unwatchFn2)
491+
unwatchFn2()
492+
mockFn1(val)
493+
})
494+
495+
unwatchFn2 = reactor.observe(subtotalGetter, (val) => {
496+
console.log('handler2')
497+
mockFn2(val)
498+
})
499+
500+
expect(function() {
501+
checkoutActions.addItem('foo', 5)
502+
expect(mockFn1.calls.count()).toEqual(1)
503+
expect(mockFn2.calls.count()).toEqual(0)
504+
expect(mockFn1.calls.argsFor(0)).toEqual([5])
505+
}).not.toThrow()
506+
})
485507
})
486508
}) // Reactor with no initial state
487509

@@ -551,6 +573,16 @@ describe('Reactor', () => {
551573

552574
expect(reactor.evaluateToJS(['persistent'])).toEqual([item])
553575
})
576+
577+
it('should be able to reset and call an unwatch() function without erroring', () => {
578+
const spy = jasmine.createSpy()
579+
const unobserve = reactor.observe(['standard'], () => spy())
580+
581+
reactor.reset()
582+
expect(function() {
583+
unobserve()
584+
}).not.toThrow()
585+
})
554586
})
555587

556588
describe('when a reactor is observing mutable values', () => {

‎webpack.config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module.exports = [
2020
},
2121
module: {
2222
loaders: [
23-
{ test: /\.js$/, loader: 'babel-loader' },
23+
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader' },
2424
],
2525
},
2626
},
@@ -33,7 +33,7 @@ module.exports = [
3333
},
3434
module: {
3535
loaders: [
36-
{ test: /\.js$/, loader: 'babel-loader' },
36+
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader' },
3737
],
3838
},
3939
plugins: [uglifyJsPlugin],

0 commit comments

Comments
 (0)
Please sign in to comment.