Created
July 10, 2014 02:45
-
-
Save louy/24c7de977f758ee9c40f to your computer and use it in GitHub Desktop.
Subscribe with Old and New Value for Knockout Subscribable
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 oldValue; | |
return [ | |
this.subscribe( function( _oldValue ) { | |
oldValue = _oldValue; | |
}, this, 'beforeChange' ), | |
this.subscribe( function( newValue ) { | |
callback( newValue, oldValue ); | |
} ) | |
]; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment