Fixed an issue: ko.isWriteableObservable incorrectly returns false for computed observables in the mapping context.#175
Conversation
…r computed observables in the mapping context.
|
This doesn't work - you get infinite recursion Should be instead of (inside the ko.isWriteableObservable function) |
|
Indeed. |
|
It's a shame the mapping seems to have been neglected - it definitely has some issues and I wish it had been maintained - but I'm stuck with using it for now :-) The reason I needed this change was I'd created a simple writeable observable to auto-convert a string or date to a proper Date object and I wanted it to work with the mapper. Making the change I suggested is working just fine. |
|
Well, glad to be of help. Good luck. |
The withProxyDependentObservable function replaces ko.dependentObservable, but does not replace ko.isWriteableObservable, which causes the latter to always return false for computeds.
At the same time, the mapping plugin itself uses isWriteableObservable a lot in the mapping process to determine whether it should use the existing observable or replace it with a new, writeable one. Since all computeds look like non-writeable at this point, the mapping procedure will replace all computeds with new observables, thus screwing up the viewmodel inner mechanics.
The solution is simple: when replacing ko.dependentObservable with a proxy, also replace ko.isWriteableObservable.