SteveSanderson/knockout — Issue #225: view value of observable in debugger
Author: mbest
Created: 2011-12-09 02:46:22+00:00
State: open

When using observables to store values, I cannot view the observable's value in a debugger because it is stored using a closure. However, if it is stored as a property of the function object, it is accessible:

In ko.observable, change:
_latestValue = arguments[0];
to
observable._latestValue = _latestValue = arguments[0];

And add right after the observable function definition:
observable._latestValue = _latestValue;

Similar code in dependentObservable makes that value accessible as well:

Add:
dependentObservable._latestValue = _latestValue;
right before:
return _latestValue;
and also before:
return dependentObservable;