Comparing version 0.4.17 to 0.4.18
@@ -5,3 +5,3 @@ // Generated by CoffeeScript 1.3.3 | ||
var Reference, assertRef, extend, getRef, isRef, mutable, notifyRef, ref, setRef, watchRef; | ||
var Reference, assertRef, extend, getRef, isRef, mutable, notifyRef, ref, setRef, unwatchRef, watchRef; | ||
@@ -58,2 +58,15 @@ extend = require('./protocol').extend; | ||
unwatchRef = function(reference, callback) { | ||
var i, x, _i, _len, _ref; | ||
assertRef(reference); | ||
_ref = reference.metadata.watches; | ||
for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) { | ||
x = _ref[i]; | ||
if (x === callback) { | ||
reference.metadata.watches.slice(i, i + 1 || 9e9); | ||
} | ||
} | ||
return true; | ||
}; | ||
notifyRef = function(reference) { | ||
@@ -84,5 +97,6 @@ var callback, _i, _len, _ref; | ||
watchRef: watchRef, | ||
notifyRef: notifyRef | ||
notifyRef: notifyRef, | ||
unwatchRef: unwatchRef | ||
}; | ||
}).call(this); |
@@ -19,4 +19,4 @@ // Generated by CoffeeScript 1.3.3 | ||
if (childElement.length > 0) { | ||
ref.metadata.children = createRef(); | ||
this.control.cosy.cmd(childElement, ['class', Tree, ref.metadata.children, list.itemTemplate]); | ||
ref.value.children = createRef(); | ||
this.control.cosy.cmd(childElement, ['class', Tree, ref.value.children, list.itemTemplate]); | ||
} | ||
@@ -23,0 +23,0 @@ } |
@@ -5,7 +5,7 @@ // Generated by CoffeeScript 1.3.3 | ||
var copy, get, notify, set, watch, watchRef, _ref; | ||
var copy, coreWatchRef, get, notify, set, unwatchRef, watch, watchRef, _ref, _ref1; | ||
_ref = require('../../protocol/mutable'), set = _ref.set, get = _ref.get; | ||
watchRef = require('../../core/reference').watchRef; | ||
_ref1 = require('../../core/reference'), coreWatchRef = _ref1.watchRef, unwatchRef = _ref1.unwatchRef; | ||
@@ -21,2 +21,5 @@ copy = function(src, tgt) { | ||
watch = function(watchedRef, watchFn) { | ||
this.destructors.push(function() { | ||
return unwatchRef(watchedRef, watchFn); | ||
}); | ||
return watchRef(watchedRef, function() { | ||
@@ -27,2 +30,9 @@ return watchFn(get(watchedRef)); | ||
watchRef = function(watchedRef, watchFn) { | ||
this.destructors.push(function() { | ||
return unwatchRef(watchedRef, watchFn); | ||
}); | ||
return coreWatchRef(watchedRef, watchFn); | ||
}; | ||
module.exports = { | ||
@@ -29,0 +39,0 @@ set: set, |
@@ -5,5 +5,6 @@ // Generated by CoffeeScript 1.3.3 | ||
var Control, control, evaluate, extend, instance, isFn, isRef, map, mutable, parseArgs, use, watchRef, _ref, _ref1, | ||
var Control, control, evaluate, extend, instance, isFn, isRef, map, mutable, parseArgs, registerChild, use, watchRef, _ref, _ref1, | ||
__hasProp = {}.hasOwnProperty, | ||
__slice = [].slice; | ||
__slice = [].slice, | ||
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; | ||
@@ -52,2 +53,13 @@ map = require('../../protocol/map'); | ||
registerChild = function(frame, child) { | ||
if (frame == null) { | ||
return; | ||
} | ||
if (frame.__control != null) { | ||
return frame.__control.children.push(child); | ||
} else if (frame !== frame.__parent) { | ||
return registerChild(frame.__parent, child); | ||
} | ||
}; | ||
instance = 0; | ||
@@ -61,2 +73,6 @@ | ||
this.frame = frame; | ||
this.destroy = __bind(this.destroy, this); | ||
this.empty = __bind(this.empty, this); | ||
if (!isFn(fn)) { | ||
@@ -71,2 +87,6 @@ if (this.frame.__parentNS != null) { | ||
this.instance = instance; | ||
this.destructors = []; | ||
this.children = []; | ||
registerChild(this.frame, this); | ||
this.frame.__control = this; | ||
apply = function() { | ||
@@ -126,3 +146,3 @@ var newArgs; | ||
if (isRef(arg)) { | ||
watchRef(arg, apply); | ||
this.watchRef(arg, apply); | ||
} | ||
@@ -135,2 +155,21 @@ } | ||
Control.prototype.empty = function() { | ||
var child; | ||
while (child = this.children.pop()) { | ||
child.destroy(); | ||
} | ||
return this.element.html(''); | ||
}; | ||
Control.prototype.destroy = function() { | ||
var fn, _i, _len, _ref2; | ||
this.empty(); | ||
_ref2 = this.destructors; | ||
for (_i = 0, _len = _ref2.length; _i < _len; _i++) { | ||
fn = _ref2[_i]; | ||
fn(); | ||
} | ||
return this.element.remove(); | ||
}; | ||
return Control; | ||
@@ -137,0 +176,0 @@ |
{ | ||
"name": "cosy-js", | ||
"version": "0.4.17", | ||
"version": "0.4.18", | ||
"description": "A cosy little library.", | ||
@@ -5,0 +5,0 @@ "keywords": [], |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
305269
7572