Example #1
0
function noUpdate(noUpdateSpec, func) {
  var globalNoUpdate = false, result;
  if (!func && typeof noUpdateSpec === "function") {
    func = noUpdateSpec; globalNoUpdate = true; }
  if (globalNoUpdate) { // rather a hack for now
    var proto = AttributeConnection.prototype;
    if (!proto.isActive) proto.isActive = 0;
    proto.isActive++;
    try { result = func(); } finally {
      proto.isActive--;
      if (proto.isActive <= 0) proto.isActive;
    }
  } else {
    var obj = noUpdateSpec.sourceObj,
        attr = noUpdateSpec.sourceAttribute,
        targetObj = noUpdateSpec.targetObj,
        targetAttr = noUpdateSpec.targetAttribute,
        filter = targetObj && targetAttr ?
          ea => ea.getSourceAttrName() === attr
                   && targetObj === ea.getTargetObj()
                   && targetAttr === ea.getTargetMethodName() :
          ea => ea.getSourceAttrName() === attr,
        conns = obj.attributeConnections && obj.attributeConnections.filter(filter);
    conns && arr.invoke(conns, 'activate');
    try { result = func(); }
    finally { conns && arr.invoke(conns,'deactivate'); }
  }
  return result;
}