Created
September 3, 2015 11:39
-
-
Save anasnakawa/a973cfed5a8717cd426a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/** | |
* knockout observable subscriber that will get triggered only once at most | |
* | |
* @param {fn} handler | |
* @param {object} [optional] context | |
*/ | |
ko.observable.fn.subscribeOnce = function( handler, context ) { | |
var subscribtion = this.subscribe(function() { | |
handler.apply( this, arguments ); | |
subscribtion.dispose(); | |
}, context ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment