src/basis/event.js
function(callbacks, context){
      /** @cut */ if (!callbacks)
      /** @cut */   basis.dev.warn(namespace + '.Emitter#addHandler: callbacks is not an object (', callbacks, ')');

      context = context || this;

      // warn about duplicates
      /** @cut */ var cursor = this;
      /** @cut */ while (cursor = cursor.handler)
      /** @cut */ {
      /** @cut */   if (cursor.callbacks === callbacks && cursor.context === context)
      /** @cut */   {
      /** @cut */     basis.dev.warn(namespace + '.Emitter#addHandler: add duplicate event callbacks', callbacks, 'to Emitter instance:', this);
      /** @cut */     break;
      /** @cut */   }
      /** @cut */ }

      // add handler
      this.handler = {
        callbacks: callbacks,
        context: context,
        handler: this.handler
      };
    }
function(callbacks, context){
      /** @cut */ if (!callbacks)
      /** @cut */   basis.dev.warn(namespace + '.Emitter#addHandler: callbacks is not an object (', callbacks, ')');

      context = context || this;

      // warn about duplicates
      /** @cut */ var cursor = this;
      /** @cut */ while (cursor = cursor.handler)
      /** @cut */ {
      /** @cut */   if (cursor.callbacks === callbacks && cursor.context === context)
      /** @cut */   {
      /** @cut */     basis.dev.warn(namespace + '.Emitter#addHandler: add duplicate event callbacks', callbacks, 'to Emitter instance:', this);
      /** @cut */     break;
      /** @cut */   }
      /** @cut */ }

      // add handler
      this.handler = {
        callbacks: callbacks,
        context: context,
        handler: this.handler
      };
    }
function ( callbacks , context ) { /** @cut */ if ( ! callbacks ) /** @cut */ basis . dev . warn ( namespace + '.Emitter#addHandler: callbacks is not an object (' , callbacks , ')' ) ; context = context || this ; // warn about duplicates /** @cut */ var cursor = this ; /** @cut */ while ( cursor = cursor . handler ) /** @cut */ { /** @cut */ if ( cursor . callbacks === callbacks && cursor . context === context ) /** @cut */ { /** @cut */ basis . dev . warn ( namespace + '.Emitter#addHandler: add duplicate event callbacks' , callbacks , 'to Emitter instance:' , this ) ; /** @cut */ break ; /** @cut */ } /** @cut */ } // add handler this . handler = { callbacks : callbacks , context : context , handler : this . handler } ; }
Adds new event handler to object.
@param {object} callbacks Callback set.
@param {object=} context Context object.
Adds new event handler to object .