Skip to content

Instantly share code, notes, and snippets.

@iskugor
Created October 23, 2012 13:53
Show Gist options
  • Save iskugor/3938865 to your computer and use it in GitHub Desktop.
Save iskugor/3938865 to your computer and use it in GitHub Desktop.
Titanium "once" function
function once(component, eventName, callback) {
if(component && component.addEventListener && eventName && callback) {
var wrappedCallback = function(e) {
component.removeEventListener(eventName, wrappedCallback);
callback.call(component, e);
};
component.addEventListener(eventName, wrappedCallback);
} else {
Ti.API.error('"once" function illegal parameter');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment