Titanium Mobile: Add event listener once respectively remove event listener for anonymous callback function
var win = Ti.UI.createWindow({
backgroundColor: 'white'
});
win.addEventListener('click', function foo(e) { // note the named function expression needed for the second way
// oringal idea by @fukhaos
// http://www.tidev.io/2014/09/10/the-case-against-ti-app-fireevent-2/#comment-13013
e.source.removeEventListener(e.type, arguments.callee);
// better - strict - one by @tonylukasavage
// https://twitter.com/tonylukasavage/status/511887565100949505
e.source.removeEventListener(e.type, foo);
alert('I will only fire once!');
});
win.open();