Is it possible in knockout to get the current value of an observable within a subscription to that observable, before it receives the new value?
Example:
<
I have found that I can call peek() from a writable computed observable to get the before value.
Something like this (see http://jsfiddle.net/4MUWp):
var enclosedObservable = ko.observable();
this.myObservable = ko.computed({
read: enclosedObservable,
write: function (newValue) {
var oldValue = enclosedObservable.peek();
alert(oldValue);
enclosedObservable(newValue);
}
});