riot-observable
Advanced tools
Comparing version 2.0.0-beta.2 to 2.0.3-beta
@@ -83,3 +83,3 @@ ;(function(window, undefined) {var observable = function(el) { | ||
var fns = callbacks[name] || [] | ||
var fns = (callbacks[name] || []).slice(0) | ||
@@ -89,4 +89,7 @@ for (var i = 0, fn; fn = fns[i]; ++i) { | ||
fn.busy = 1 | ||
fn.apply(el, fn.typed ? [name].concat(args) : args) | ||
if (fns[i] !== fn) i-- | ||
// avoid that this fn.busy gets stuck in case of errors it fixes #3 | ||
try { | ||
fn.apply(el, fn.typed ? [name].concat(args) : args) | ||
} catch (e) { /* error */} | ||
if (fns[i] !== fn) { i-- } | ||
fn.busy = 0 | ||
@@ -93,0 +96,0 @@ } |
@@ -83,3 +83,3 @@ riot.observable = function(el) { | ||
var fns = callbacks[name] || [] | ||
var fns = (callbacks[name] || []).slice(0) | ||
@@ -89,4 +89,7 @@ for (var i = 0, fn; fn = fns[i]; ++i) { | ||
fn.busy = 1 | ||
fn.apply(el, fn.typed ? [name].concat(args) : args) | ||
if (fns[i] !== fn) i-- | ||
// avoid that this fn.busy gets stuck in case of errors it fixes #3 | ||
try { | ||
fn.apply(el, fn.typed ? [name].concat(args) : args) | ||
} catch (e) { /* error */} | ||
if (fns[i] !== fn) { i-- } | ||
fn.busy = 0 | ||
@@ -93,0 +96,0 @@ } |
@@ -83,3 +83,3 @@ var observable = function(el) { | ||
var fns = callbacks[name] || [] | ||
var fns = (callbacks[name] || []).slice(0) | ||
@@ -89,4 +89,7 @@ for (var i = 0, fn; fn = fns[i]; ++i) { | ||
fn.busy = 1 | ||
fn.apply(el, fn.typed ? [name].concat(args) : args) | ||
if (fns[i] !== fn) i-- | ||
// avoid that this fn.busy gets stuck in case of errors it fixes #3 | ||
try { | ||
fn.apply(el, fn.typed ? [name].concat(args) : args) | ||
} catch (e) { /* error */} | ||
if (fns[i] !== fn) { i-- } | ||
fn.busy = 0 | ||
@@ -93,0 +96,0 @@ } |
{ | ||
"name": "riot-observable", | ||
"version": "2.0.0-beta.2", | ||
"version": "2.0.3-beta", | ||
"description": "Simple script to send and receive events", | ||
@@ -22,9 +22,9 @@ "main": "dist/observable.js", | ||
"devDependencies": { | ||
"coveralls": "^2.11.3", | ||
"eslint": "^1.0.0", | ||
"coveralls": "^2.11.4", | ||
"eslint": "^1.4.1", | ||
"expect.js": "^0.3.1", | ||
"karma": "^0.13.3", | ||
"karma-coverage": "^0.4.2", | ||
"karma": "^0.13.9", | ||
"karma-coverage": "^0.5.2", | ||
"karma-mocha": "^0.2.0", | ||
"karma-phantomjs-launcher": "^0.2.0" | ||
"karma-phantomjs-launcher": "^0.2.1" | ||
}, | ||
@@ -31,0 +31,0 @@ "author": "Muut, Inc. and other contributors", |
@@ -141,3 +141,3 @@ describe('Core specs', function() { | ||
el.on('e1', function() { this.trigger('e2') }) | ||
el.on('e1', function() { e2 = true }) | ||
el.on('e2', function() { e2 = true }) | ||
@@ -291,3 +291,30 @@ el.trigger('e1') | ||
it('Do not block callback throwing errors', function(done) { | ||
el.on('event', function() { counter++; throw 'OH NOES!' }) | ||
el.on('event', function() { counter++ }) | ||
el.trigger('event') | ||
setTimeout(function() { | ||
el.trigger('event') | ||
expect(counter).to.be(4) | ||
done() | ||
}, 1000) | ||
}) | ||
it('The one event is called once also in a recursive function', function() { | ||
el.one('event', function() { | ||
counter ++ | ||
el.one('event', function() { | ||
counter ++ | ||
}) | ||
}) | ||
el.trigger('event') | ||
expect(counter).to.be(1) | ||
el.trigger('event') | ||
expect(counter).to.be(2) | ||
}) | ||
}) | ||
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
40275
531