Skip to content

Instantly share code, notes, and snippets.

@jonathancounihan
Last active August 29, 2015 14:02
Show Gist options
  • Save jonathancounihan/b35d82446da7ca58ea6a to your computer and use it in GitHub Desktop.
Save jonathancounihan/b35d82446da7ca58ea6a to your computer and use it in GitHub Desktop.
knockout subscribeChanged (Thanks to mbest!)
ko.subscribable.fn.subscribeChanged = function (callback) {
var savedValue = this.peek();
return this.subscribe(function (latestValue) {
var oldValue = savedValue;
savedValue = latestValue;
callback(latestValue, oldValue);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment