binds event only once to handler

@param  {String} eventName   push, pull, connect, disconnect
@param  {Function} handler   function once bound to event
@return {Promise}
762082
function one (state, eventName, handler) {
  state.emitter.once(eventName, handler)

  return state.api
}
808326
function(events, name, callback, context, ctx) {
  if (callback) {
    var handlers = events[name] || (events[name] = []);
    handlers.push({callback: callback, context: context, ctx: context || ctx});
  }
  return events;
}
1206338
function _connect(nodeOrId, event, eventHandler) {
		var node = lib.node(nodeOrId);
		if (node) {
			node.addEventListener(event, eventHandler, false);
		}
	}
1125685
function connect(node, type, handler, disconnect) {
    if (typeof node.addEventListener == "function") {
      node.addEventListener(type, handler, false);
      if (disconnect) return function() {node.removeEventListener(type, handler, false);};
    } else {
      var wrapHandler = function(event) {handler(event || window.event);};
      node.attachEvent("on" + type, wrapHandler);
      if (disconnect) return function() {node.detachEvent("on" + type, wrapHandler);};
    }
  }
1212435
protected void enqueueEvent(Object event, EventHandler handler) {
    eventsToDispatch.get().offer(new EventWithHandler(event, handler));
  }
744940
function Listener(handler, once) {
  assert(typeof handler === 'function', '`handler` must be a function.');
  assert(typeof once === 'boolean', '`once` must be a function.');
  this.handler = handler;
  this.once = once;
}
1216651
function addHandler(node, eventType, handler, thisObject){
    node = getNode(node);

    if (!node)
      throw 'basis.event.addHandler: can\'t attach event listener to undefined';

    if (typeof handler != 'function')
      throw 'basis.event.addHandler: handler is not a function';

    var handlers = node === global ? globalEvents : node[EVENT_HOLDER];

    if (!handlers)
      handlers = node[EVENT_HOLDER] = {};

    var eventTypeHandlers = handlers[eventType];
    var handlerObject = {
      handler: handler,
      thisObject: thisObject
    };

    if (!eventTypeHandlers)
    {
      eventTypeHandlers = handlers[eventType] = [handlerObject];
      eventTypeHandlers.fireEvent = function(event){ // closure
        // simulate capture phase for old browsers
        event = wrap(event);
        if (noCaptureScheme && event && globalHandlers[eventType])
        {
          if (typeof event.returnValue == 'undefined')
          {
            observeGlobalEvents(event);
            if (event.cancelBubble === true)
              return;
            if (typeof event.returnValue == 'undefined')
              event.returnValue = true;
          }
        }

        startFrame(event);

        // call eventType handlers
        for (var i = 0, wrappedEvent = new Event(event), item; item = eventTypeHandlers[i++];)
          item.handler.call(item.thisObject, wrappedEvent);

        finishFrame(event);
      };

      if (W3CSUPPORT)
        // W3C DOM event model
        node.addEventListener(eventType, eventTypeHandlers.fireEvent, false);
      else
        // old IE event model
        node.attachEvent('on' + eventType, eventTypeHandlers.fireEvent);
    }
    else
    {
      // check for duplicates, exit if found
      for (var i = 0, item; item = eventTypeHandlers[i]; i++)
        if (item.handler === handler && item.thisObject === thisObject)
          return;

      // add only unique handlers
      eventTypeHandlers.push(handlerObject);
    }
  }
513792
function createDispatcher(eventName){
    var eventFunction = events[eventName];

    if (!eventFunction)
    {
      eventFunction = function(){
        var cursor = this;
        var args;
        var fn;

        while (cursor = cursor.handler)
        {
          // callback call
          fn = cursor.callbacks[eventName];
          if (typeof fn == 'function')
          {
            if (!args)
            {
              // it should be better for browser optimizations
              // (instead of [this].concat(slice.call(arguments)))
              args = [this];
              for (var i = 0; i < arguments.length; i++)
                args.push(arguments[i]);
            }

            fn.apply(cursor.context || this, args);
          }

          // any event callback call
          fn = cursor.callbacks['*'];
          if (typeof fn == 'function')
          {
            if (!args)
            {
              // it should be better for browser optimizations
              // (instead of [this].concat(slice.call(arguments)))
              args = [this];
              for (var i = 0; i < arguments.length; i++)
                args.push(arguments[i]);
            }

            fn.call(cursor.context || this, {
              sender: this,
              type: eventName,
              args: args
            });
          }
        }

        // feature available in development mode only
        /** @cut */ if (this.debug_emit)
        /** @cut */ {
        /** @cut */   args = [];  // avoid optimization warnings about arguments
        /** @cut */   for (var i = 0; i < arguments.length; i++)
        /** @cut */     args.push(arguments[i]);
        /** @cut */   this.debug_emit({
        /** @cut */     sender: this,
        /** @cut */     type: eventName,
        /** @cut */     args: args
        /** @cut */   });
        /** @cut */ }
      };

      // function wrapper for more verbose in development mode
      /** @cut */ eventFunction = new Function(
      /** @cut */   'return {"' + namespace + '.events.' + eventName + '":\n\n      ' +
      /** @cut */
      /** @cut */     'function(' + basis.array(arguments, 1).join(', ') + '){' +
      /** @cut */       eventFunction.toString()
      /** @cut */         .replace(/\beventName\b/g, '"' + eventName + '"')
      /** @cut */         .replace(/^function[^(]*\(\)[^{]*\{|\}$/g, '') +
      /** @cut */     '}' +
      /** @cut */
      /** @cut */   '\n\n}["' + namespace + '.events.' + eventName + '"];'
      /** @cut */ )();

      events[eventName] = eventFunction;
    }

    return eventFunction;
  }
278747
function on (state, eventName, handler) {
  state.emitter.on(eventName, handler)

  return state.api
}
914941
function(eventName, handler, elem) {
  if (elem.addEventListener) {
    // Setting useCapture to true so that this virtual handler is always fired first
    // Also handles events that don't bubble correctly like focus/blur
    elem.addEventListener(eventName, handler, true);
  } else {
    elem.attachEvent('on' + eventName, handler);
  }
}
559150
function(name, callback, scope, once) {

            var events = null;
            if (!(events = this._events[name])) {
                events = this._events[name] = [];
            }

            events.push({
                callback: callback,
                scope: scope || this,
                once: once,
                fired: false
            });

            return callback;

        }
217489
function(events, name, callback, options) {
    if (callback) {
      var handlers = events[name] || (events[name] = []);
      var context = options.context, ctx = options.ctx, listening = options.listening;
      if (listening) listening.count++;

      handlers.push({callback: callback, context: context, ctx: context || ctx, listening: listening});
    }
    return events;
  }
1286012
function delegateHandler(evt, selector, handler) {
    const scopeSelector = `[${randomID}="${randomID}"] `;
    const splittedSelector = selector.split(',');

    let matching = '';

    for (let i = 0; i < splittedSelector.length; i++) {
        const sel = splittedSelector[i];
        matching += `${i === 0 ? '' : ','}${scopeSelector}${sel},${scopeSelector}${sel} *`;
    }


    this.setAttribute(randomID, randomID);

    if (is(evt.target, matching)) {
        handler.call(this, evt);
    }

    this.removeAttribute(randomID);
}
457583
function onEvent(gesture, handler) {
    var gestures = gesture.split(' ');
    Utils.each(gestures, function(gesture) {
      this.element.addEventListener(gesture, handler, false);
      this.eventHandlers.push({ gesture: gesture, handler: handler });
    }, this);
    return this;
  }
1365259
function removeEventListener(el, eventName, handler) {
    if (window.jQuery) {
      $(el).off(eventName, handler);
    } else if (el.removeEventListener) {
      el.removeEventListener(eventName, handler);
    } else {
      el.detachEvent('on' + eventName, handler);
    }
  }
258445
function onEvent(gesture, handler){
      var gestures = gesture.split(' ');
      for(var t=0; t<gestures.length; t++) {
        this.element.addEventListener(gestures[t], handler, false);
      }
      return this;
    }
1367789
function _connectHandler(self) {
      return function() {
        // Assign
        var connection = this;

        // Pool destroyed stop the connection
        if (self.state === DESTROYED || self.state === DESTROYING) {
          return connection.destroy();
        }

        // Clear out all handlers
        handlers.forEach(function(event) {
          connection.removeAllListeners(event);
        });

        // Reset reconnect id
        self.reconnectId = null;

        // Apply pool connection handlers
        connection.on('error', connectionFailureHandler(self, 'error'));
        connection.on('close', connectionFailureHandler(self, 'close'));
        connection.on('timeout', connectionFailureHandler(self, 'timeout'));
        connection.on('parseError', connectionFailureHandler(self, 'parseError'));

        // Apply any auth to the connection
        reauthenticate(self, this, function() {
          // Reset retries
          self.retriesLeft = self.options.reconnectTries;
          // Push to available connections
          self.availableConnections.push(connection);
          // Set the reconnectConnection to null
          self.reconnectConnection = null;
          // Emit reconnect event
          self.emit('reconnect', self);
          // Trigger execute to start everything up again
          _execute(self)();
        });
      };
    }