Fires an event asynchronously. Event listeners are invoked
on the next tick rather than immediately.
@param {string} event the event to fire
@param {...*} arguments to pass to the event listeners
@returns {Object} this trigger object
170453
function fireAsync(event) {
		var args = Array.prototype.slice.call(arguments);
		setTimeout(function() {
			fire.apply(triggerObject, args);
		}, 0);
		return triggerObject;
	}
1356994
private <H extends EventHandler> void scheduleEvent(final DomEvent<H> event) {
    DeferredCommand.addCommand(new Command() {
      public void execute() {
        onEvent(event);
      }
    });
  }
968173
@SuppressWarnings("unchecked")
  public Listener<Void> onEvent(String event, Runnable callback) {
    return onEvent(event, v -> callback.run());
  }
85787
public function triggerEvent($event, $args = [])
    {
        if (!($event instanceof EventInterface)) {
            if (isset($this->events[$event])) {
                $event = $this->events[$event];
            } else {
                $event = new Event($event);
            }
        }

        $event->mergeArguments($args);

        if (isset($this->listeners[$event->getName()])) {
            foreach ($this->listeners[$event->getName()] as $listener) {
                if ($event->isStopped()) {
                    return $event;
                }

                if (is_callable($listener)) {
                    call_user_func($listener, $event);
                } else {
                    call_user_func([$listener, $event->getName()], $event);
                }
            }
        }

        return $event;
    }
1153264
function(event /* params */) {

            var listeners;
            var that = this;
            var params = _.toArray(arguments).slice(1);

            listeners = this.__getEventListeners(event);

            _.each(listeners, function(listener) {
                listener.apply(that, params);
            });

            listeners = this.__getEventListeners('event.emit');

            _.each(listeners, function(listener) {
                listener.call(that, event, params);
            });

            return this;
        }
1143705
public function fire(string $event, array $arguments = null) {
        $arguments = (array)$arguments;
        foreach ($this->getBindings($event) as $callback) {
            if (is_callable($callback)) {
                call_user_func_array($callback, $arguments);
            }
        }
    }
1347001
@Override
	public void fireEvent(String event) throws WidgetException {
		try {
			String javaScript = null;
			if (event.startsWith("mouse")) {
				javaScript = "if(document.createEvent){var evObj = document.createEvent('MouseEvents');evObj.initEvent('" + event
						+ "', true, false); arguments[0].dispatchEvent(evObj);} else if(document.createEventObject) { arguments[0].fireEvent('on" + event + "');}";
			} else {
				javaScript = "if(document.createEvent){var evObj = document.createEvent('HTMLEvents');evObj.initEvent('" + event
						+ "', true, false); arguments[0].dispatchEvent(evObj);} else if(document.createEventObject) { arguments[0].fireEvent('on" + event + "');}";
			}
			eval(javaScript);
		} catch (Exception e) {
			throw new WidgetException("Error while trying to fire event", getByLocator(), e);
		}
	}
496725
public void fire(T event) {
		ArrayList<Listener<T>> list1;
		ArrayList<Runnable> list2;
		synchronized (this) {
			if (listeners == null) list1 = null;
			else list1 = new ArrayList<>(listeners);
			if (listenersRunnable == null) list2 = null;
			else list2 = new ArrayList<>(listenersRunnable);
		}
		if (list1 != null)
			for (int i = 0; i < list1.size(); ++i)
				try { list1.get(i).fire(event); }
				catch (Throwable t) {
					LCCore.getApplication().getDefaultLogger().error("Event listener error: " + list1.get(i), t);
				}
		if (list2 != null)
			for (int i = 0; i < list2.size(); ++i)
				try { list2.get(i).run(); }
				catch (Throwable t) {
					LCCore.getApplication().getDefaultLogger().error("Event listener error: " + list2.get(i), t);
				}
	}
790458
function (object, event, callback) {
        var index = this.indexOf(object);
        var listener = this.listeners[index];
        if (!listener) {
            listener = {
                'object': object,
                'events': {}
            };
            this.listeners.push(listener);
        }

        var callbacks = listener.events[event];
        if (!callbacks) {
            callbacks = [];
            listener.events[event] = callbacks;
        }

        // add the callback if it does not yet exist
        if (callbacks.indexOf(callback) == -1) {
            callbacks.push(callback);
        }
    }
1213452
function(event){
        if (typeof event == "string"){
            event = { type: event };
        }
        if (!event.target){
            event.target = this;
        }

        if (!event.type){
            throw new Error("Event object missing 'type' property.");
        }

        if (this._handlers[event.type] instanceof Array){
            var handlers = this._handlers[event.type];
            for (var i=0, len=handlers.length; i < len; i++){
                handlers[i].call(this, event);
            }
        }
    }
733407
function EventEmitter() {
    var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

    _classCallCheck(this, EventEmitter);

    this._events = {};
    if (opts.async) this.emit = emitAsync;
  }
948478
def asynchronous(function, event):
    
    thread = Thread(target=synchronous, args=(function, event))
    thread.daemon = True
    thread.start()
515669
def trigger(self, event, **kwargs):
        
        with self._handlers.trigger_mutex:
            event = prime_event(event, self.__class__.__name__, **kwargs)

            for handler in self._handlers.async_handlers[event]:
                asynchronous(handler, event)
            for handler in self._handlers.sync_handlers[event]:
                synchronous(handler, event)
695574
function() {

    this.on = this.addEventListener = function(type, listener) {
        if (!this.events[type]) {
            this.events[type] = [];
        }

        this.events[type].push(listener);
    };

    this.off = this.removeEventListener = function (type, listener) {
        if (!!this.events[type]) {
            for(var i = 0; i < this.events[type].length; i++) {
                if (this.events[type][i] === listener) {
                    this.events[type][i] = null;
                    this.events[type].splice(i, 1);
                    return;
                }
            }
        }
    };

    this.removeAllListeners = function (type) {
        this.events[type] = [];
    };

    var emit = function(cb, event) {
        // Handle callbacks asynchronously
        setTimeout(function() {
            cb(event);
        }, 0);

    };

    this.dispatchEvent = function (event) {
        if (!!event.type) {
            var type = event.type;
            if (!!this.events[type]) {
                event.target = this;
                for (var i = 0; i < this.events[type].length && (event.returnValue === undefined || event.returnValue) ; i++) {
                    var cb = this.events[type][i];
                    // Dereference cb for async
                    emit(cb.bind(event.target), event);
                }
            }
        }
    };
}
1337721
def fire(self, event):
        
        self.browser.fire(self.element, event)
        return self
54628
def dispatch(self, event, *args):
        

        for callback in self.listeners.get(event, []):
            if len(args) > 0:
                callback(*args)
            else:
                callback()
667618
public function trigger($event, $args = array())
	{
		if (!($event instanceof Event))
		{
			if (isset($this->events[$event]))
			{
				$event = $this->events[$event];
			}
			else
			{
				$event = new Event($event);
			}
		}

		// If a listener group was specified
		// lazy load the listeners.
		if ($group = $event->getGroup())
		{
			$this->addListeners($group);
		}

		// Attach any incoming aruments
		foreach ((array) $args as $name => $arg)
		{
			$event->addArgument($name, $arg);
		}

		// Are there any listeners for this event?
		if (isset($this->listeners[$event->getName()]))
		{
			foreach ($this->listeners[$event->getName()] as $listener)
			{
				// Call the event listener
				if ($listener instanceof Closure)
				{
					$response = call_user_func($listener, $event);
				}
				else
				{
					$response = call_user_func(array($listener, $event->getName()), $event);
				}

				// Attach response
				if (!is_null($response))
				{
					$event->addResponse($response);
				}

				// Is propagation stopped?
				if ($event->isStopped())
				{
					break;
				}
			}
		}

		return $event->getResponse();
	}