src/Emitter.js
function(eventIdentifier, callback, context) {
		if (typeof callback !== 'function') { throw new TypeError('once: Illegal Argument: callback must be a function, was ' + (typeof callback)); }

		var off = this.off.bind(this), hasFired = false;

		function onceEventHandler() {
			if (hasFired === false) {
				hasFired = true;
				off(eventIdentifier, onceEventHandler, context);
				callback.apply(this, arguments);
			}
		}
		// We need this to enable us to remove the wrapping event handler
		// when off is called with the original callback.
		onceEventHandler._onceFunctionMarker = ONCE_FUNCTION_MARKER;
		onceEventHandler._wrappedCallback = callback;

		this.on(eventIdentifier, onceEventHandler, context);
	}
function(eventIdentifier, callback, context) {
		if (typeof callback !== 'function') { throw new TypeError('once: Illegal Argument: callback must be a function, was ' + (typeof callback)); }

		var off = this.off.bind(this), hasFired = false;

		function onceEventHandler() {
			if (hasFired === false) {
				hasFired = true;
				off(eventIdentifier, onceEventHandler, context);
				callback.apply(this, arguments);
			}
		}
		// We need this to enable us to remove the wrapping event handler
		// when off is called with the original callback.
		onceEventHandler._onceFunctionMarker = ONCE_FUNCTION_MARKER;
		onceEventHandler._wrappedCallback = callback;

		this.on(eventIdentifier, onceEventHandler, context);
	}
function ( eventIdentifier , callback , context ) { if ( typeof callback !== 'function' ) { throw new TypeError ( 'once: Illegal Argument: callback must be a function, was ' + ( typeof callback ) ) ; } var off = this . off . bind ( this ) , hasFired = false ; function onceEventHandler ( ) { if ( hasFired === false ) { hasFired = true ; off ( eventIdentifier , onceEventHandler , context ) ; callback . apply ( this , arguments ) ; } } // We need this to enable us to remove the wrapping event handler // when off is called with the original callback. onceEventHandler . _onceFunctionMarker = ONCE_FUNCTION_MARKER ; onceEventHandler . _wrappedCallback = callback ; this . on ( eventIdentifier , onceEventHandler , context ) ; }
Registers a listener to receive an event only once.

If context is provided, then the <code>this</code> pointer will refer to it
inside the callback.

@param {*} eventIdentifier The identifier of the event that the callback should listen to.
@param {function} callback The function that should be called the first time the event is triggered.  May not be null.
@param {?Object} [context] An optional context that defines what 'this' should be inside the callback.
Registers a listener to receive an event only once .