Last active
August 29, 2015 14:02
-
-
Save jonathancounihan/b35d82446da7ca58ea6a to your computer and use it in GitHub Desktop.
knockout subscribeChanged (Thanks to mbest!)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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