Created
June 19, 2018 19:45
-
-
Save Vchekryzhov/0793571f4ec9012bbdd3af12aa32f391 to your computer and use it in GitHub Desktop.
subscribe knockout with old value
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