reactivity
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -8,2 +8,5 @@ // Generated by CoffeeScript 1.6.3 | ||
@public_api ( with handlers ) | ||
It also implements a subset of the EventEmitter API | ||
on, off and emit | ||
*/ | ||
@@ -13,3 +16,4 @@ | ||
(function() { | ||
var Base; | ||
var Base, | ||
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; | ||
@@ -38,2 +42,40 @@ module.exports = Base = (function() { | ||
Base.prototype.__listeners = null; | ||
Base.prototype._l = function(event) { | ||
return this.__listeners != null ? this.__listeners : this.__listeners = {}; | ||
}; | ||
Base.prototype.listeners = function(event) { | ||
return this._l()[event] || []; | ||
}; | ||
Base.prototype.on = function(event, listener) { | ||
var arr, _base; | ||
arr = ((_base = this._l())[event] != null ? (_base = this._l())[event] : _base[event] = []); | ||
if (__indexOf.call(arr, listener) < 0) { | ||
arr.push(listener); | ||
} | ||
return void 0; | ||
}; | ||
Base.prototype.off = function(event, listener) { | ||
var arr, l, x; | ||
l = this._l(); | ||
if ((arr = l[event]) != null) { | ||
l[event] = (function() { | ||
var _i, _len, _results; | ||
_results = []; | ||
for (_i = 0, _len = arr.length; _i < _len; _i++) { | ||
x = arr[_i]; | ||
if (x !== listener) { | ||
_results.push(x); | ||
} | ||
} | ||
return _results; | ||
})(); | ||
} | ||
return void 0; | ||
}; | ||
return Base; | ||
@@ -40,0 +82,0 @@ |
@@ -35,8 +35,4 @@ // Generated by CoffeeScript 1.6.3 | ||
return (function(m) { | ||
var n; | ||
if ((n = m.evaluation$create_notifier()) != null) { | ||
return n.public_api; | ||
} else { | ||
return void 0; | ||
} | ||
var _ref; | ||
return (_ref = m.evaluation$create_notifier()) != null ? _ref.public_api : void 0; | ||
})(this.m != null ? this.m : this.m = new Monitor); | ||
@@ -43,0 +39,0 @@ }; |
@@ -28,11 +28,17 @@ // Generated by CoffeeScript 1.6.3 | ||
this.evaluation$create_notifier = __bind(this.evaluation$create_notifier, this); | ||
this.onCancel = __bind(this.onCancel, this); | ||
this.onChange = __bind(this.onChange, this); | ||
var _this = this; | ||
this.notifiers = []; | ||
this.cancel_handlers = []; | ||
this.change_handlers = []; | ||
this.public_api = { | ||
onChange: this.onChange, | ||
onCancel: this.onCancel, | ||
onChange: function(f) { | ||
return _this.on('change', f); | ||
}, | ||
onCancel: function(f) { | ||
return _this.on('cancel', f); | ||
}, | ||
on: function(e, l) { | ||
return _this.on(e, l); | ||
}, | ||
off: function(e, l) { | ||
return _this.off(e, l); | ||
}, | ||
destroy: this.user$destroy, | ||
@@ -45,13 +51,5 @@ state: function() { | ||
Monitor.prototype.onChange = function(f) { | ||
return this.change_handlers.push(f); | ||
}; | ||
Monitor.prototype.onCancel = function(f) { | ||
return this.cancel_handlers.push(f); | ||
}; | ||
Monitor.prototype.handle_cancel = function() { | ||
var x, _i, _len, _ref, _results; | ||
_ref = this.cancel_handlers; | ||
_ref = this.listeners('cancel'); | ||
_results = []; | ||
@@ -67,3 +65,3 @@ for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
var x, _i, _len, _ref, _results; | ||
_ref = this.change_handlers; | ||
_ref = this.listeners('change'); | ||
_results = []; | ||
@@ -70,0 +68,0 @@ for (_i = 0, _len = _ref.length; _i < _len; _i++) { |
@@ -31,8 +31,14 @@ // Generated by CoffeeScript 1.6.3 | ||
this.user$fire = __bind(this.user$fire, this); | ||
this.onCancel = __bind(this.onCancel, this); | ||
this.cancel_handlers = []; | ||
this.public_api = f = function() { | ||
return _this.user$fire(); | ||
}; | ||
f.onCancel = this.onCancel; | ||
f.onCancel = function(l) { | ||
return _this.on('cancel', l); | ||
}; | ||
f.on = function(e, l) { | ||
return _this.on(e, l); | ||
}; | ||
f.off = function(e, l) { | ||
return _this.off(e, l); | ||
}; | ||
f.state = function() { | ||
@@ -46,9 +52,5 @@ return _this.state; | ||
Notifier.prototype.onCancel = function(f) { | ||
return this.cancel_handlers.push(f); | ||
}; | ||
Notifier.prototype.handle_cancel = function() { | ||
var x, _i, _len, _ref, _results; | ||
_ref = this.cancel_handlers; | ||
_ref = this.listeners('cancel'); | ||
_results = []; | ||
@@ -55,0 +57,0 @@ for (_i = 0, _len = _ref.length; _i < _len; _i++) { |
{ | ||
"name": "reactivity", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Native Reactivity for Javascript", | ||
@@ -5,0 +5,0 @@ "author": "Aldo Bucchi <aldo.bucchi@gmail.com>", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
21579
454
0