使用knockout options.deferUpdates = true;导致微风导航属性的问题?

时间:2016-11-28 12:37:57

标签: knockout.js breeze

我想使用全局淘汰赛选项

ko.options.deferUpdates = true; 

http://knockoutjs.com/documentation/deferred-updates.html

如果我设置此选项,则会出现以下错误:

  

knockout.debug.js:419 Uncaught Error:集合导航属性   可能不会被设置。       在Function.koObj.equalityComparer(http://localhost:22657/bower_components/breeze-client/breeze.debug.js:17602:17)       在Function.isDifferent(http://localhost:22657/bower_components/knockout/dist/knockout.debug.js:1394:70)       在http://localhost:22657/bower_components/knockout/dist/knockout.debug.js:1358:22       at processTasks(http://localhost:22657/bower_components/knockout/dist/knockout.debug.js:1087:25)       在MutationObserver.scheduledProcess(http://localhost:22657/bower_components/knockout/dist/knockout.debug.js:1097:9

如果删除行ko.options.deferUpdates = true; ...则不会发生此问题。我使用knockout 3.4.1和breeze-client 1.5.16。

这个问题很难为我调试。部分微风代码:

      if (prop.isScalar) {
        if (propDescr) {
          Object.defineProperty(entity, propName, {
            enumerable: true,
            configurable: true,
            writable: true,
            value: koObj
          });
        } else {
          var koExt = koObj.extend({ intercept: { instance: entity, property: prop } });
          entity[propName] = koExt;
        }
      } else {
        val._koObj = koObj;
        // code to suppress extra breeze notification when
        // ko's array methods are called.
        koObj.subscribe(onBeforeChange, null, "beforeChange");
        // code to insure that any direct breeze changes notify ko
        val.arrayChanged.subscribe(onArrayChanged);

        koObj.equalityComparer = function () {
          throw new Error("Collection navigation properties may NOT be set.");
        };
        entity[propName] = koObj;
      }

线koObj.equalityComparer = ...可能是个错误吗? 或者我是否需要对我的代码进行一些更改才能使knockout deferUpdates选项与微风很好地配合?

0 个答案:

没有答案