Answers for "knockout js get old and new value"

0

knockout js get old and new value

ko.subscribable.fn.subscribeChanged = function (callback) {
    var savedValue = this.peek();
    return this.subscribe(function (latestValue) {
        var oldValue = savedValue;
        savedValue = latestValue;
        callback(latestValue, oldValue);
    });
};

//example use
function Mvvm() {
	var self = this;
	self.Input = ko.observable();
  
    self.Input.subscribeChanged(function (newValue, oldValue) {
        console.log("new value: " + newValue);
        console.log("old value: " + oldValue);
    });
}
Posted by: Guest on March-15-2021

Code answers related to "knockout js get old and new value"

Code answers related to "Javascript"

Browse Popular Code Answers by Language