Possible Bug: Breeze.js 1.5 — Cannot write a value to a ko.computed unless you specify a 'write' option

爱⌒轻易说出口 提交于 2019-12-24 17:23:21

问题


I think I found a bug...

Just updated to the new Breeze.JS v1.5 and now I'm getting the following error:

Error: Cannot write a value to a ko.computed unless you specify a 'write' option. If you wish to read the current value, don't pass any parameters.
   at dependentObservable (http://localhost:54663/Scripts/knockout-3.2.0.debug.js:1712:17)
   at setDpValueSimple (http://localhost:54663/Scripts/breeze.debug.js:5083:5)
   at defaultPropertyInterceptor (http://localhost:54663/Scripts/breeze.debug.js:4945:13)
   at write (http://localhost:54663/Scripts/breeze.debug.js:16415:25)
   at dependentObservable (http://localhost:54663/Scripts/knockout-3.2.0.debug.js:1710:17)
   at proto.setProperty (http://localhost:54663/Scripts/breeze.debug.js:16454:13)
   at Anonymous function (http://localhost:54663/Scripts/breeze.debug.js:7918:21)
   at proto._updateTargetFromRaw (http://localhost:54663/Scripts/breeze.debug.js:7891:9)
   at updateEntity (http://localhost:54663/Scripts/breeze.debug.js:14782:9)
   at mergeEntity (http://localhost:54663/Scripts/breeze.debug.js:14755:13)

Any ideas the best way to fix this real quick?

UPDATE: Here's my proposed fix at line 5083 in breeze.debug.js from this:

rawAccessorFn(newValue);

to this:

if (ko.isWriteableObservable(rawAccessorFn))
    rawAccessorFn(newValue);

Not sure of any underlying issues with this fix but it works for me :)

UPDATE 2: The Fix is NOW at line 5167 in breeze.debug.js v1.5.1

UPDATE 3: The Fix is NOW at line 5191 in breeze.debug.js v1.5.2

Can we get this FIX implemented in the source?


回答1:


We haven't changed the breeze knockout adapter is quite awhile. What version were you running previously?




回答2:


So tho is an unmapped property, yes? And its value is determined how? By computation from other properties and data, yes?

So who is trying to set the value? You or Breeze? If Breeze, under what circumstances?

I ask all of these questions because it is not obvious to me that silently ignoring an attempt to set a RO property is better than throwing. Seems to me that Ko is telling you something important.

I would make such a change if breeze were setting the property in some internal phase that you can't touch (e.g. during query result processing or entity import).

A small repro on jsfiddle or plunker would really help.

Thanks.



来源:https://stackoverflow.com/questions/26393484/possible-bug-breeze-js-1-5-cannot-write-a-value-to-a-ko-computed-unless-you

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!