1ko.subscribable.fn.subscribeChanged = function (callback) {
2 var savedValue = this.peek();
3 return this.subscribe(function (latestValue) {
4 var oldValue = savedValue;
5 savedValue = latestValue;
6 callback(latestValue, oldValue);
7 });
8};
9
10//example use
11function Mvvm() {
12 var self = this;
13 self.Input = ko.observable();
14
15 self.Input.subscribeChanged(function (newValue, oldValue) {
16 console.log("new value: " + newValue);
17 console.log("old value: " + oldValue);
18 });
19}
20
21