Fire an event and call the listeners.

@param  string|object $event
@param  mixed         $payload
@param  bool          $halt

@return array|null
972996
public function dispatch($event, $payload = [], $halt = false)
    {
        $this->firing[] = $event;

        foreach ($this->getListeners($event) as $listener) {
            $payload = call_user_func_array($listener, (array) $payload);
        }

        array_pop($this->firing);

        return $payload;
    }
1156954
public function fire(string $event, ...$args): void
    {
        if (!isset(self::$events[$event])) {
            return;
        }

        // call event handlers of the event.
        foreach ((array)self::$eventHandlers[$event] as $cb) {
            // return FALSE to stop go on handle.
            if (false === PhpHelper::call($cb, ...$args)) {
                break;
            }
        }

        // is a once event, remove it
        if (self::$events[$event]) {
            $this->off($event);
        }
    }
344170
public function fail(\Exception $error = null, array $payload = []): void
    {
        $this->fire(new Event\SagaFailed($this, $payload, $error));
    }
1059688
public function triggerEvent($event, Payload $payload)
    {
        if ($payload->state() === null) {
            $this->updatePayload($this->process->initialState(), $payload);
        }

        $state = $this->process->state($payload->state());

        $nextStateName = $state->triggerEvent($event, $payload);
        if ($nextStateName === null) {
            return;
        }

        $state = $this->process->state($nextStateName);

        $this->updatePayload($state, $payload);
        $this->handleOnStateWasSet($state, $payload);
    }
879427
public function process( array $stages, $payload )
    {
        foreach ($stages as $stage) {
            if (is_null( $payload )) {
                return null;
            }

            $payload = call_user_func_array( $stage, [ $payload ] );
        }

        return $payload;
    }
226672
protected function fireEvent($name, $payload = null)
    {
        if (! isset(static::$dispatcher)) {
            $this->initEventDispatcher();
        }

        static::$dispatcher->fire($name, $payload);
    }
748524
public function process($payload, callable $stage, callable $fallback = null)
    {
        try {
            return $stage($payload);
        }
        catch ( \Throwable $exception ) {
            if ( is_callable($fallback) ) {
                return $fallback($payload);
            }
            else {
                throw $exception;
            }
        }
    }
675423
public function trigger($event, \Closure $callback = null)
    {
        $results = [];

        if (!$event instanceof EventInterface) {
            $event = new Event($event);
        }

        if ($listeners = $this->getListeners($event->getName())) {
            foreach ($listeners as $listener) {
                $result = call_user_func($listener, $event);
                if ($result instanceof EventInterface) {
                    // Save result
                    $results[] = clone $result;

                    // Was the queue halted early ?
                    if ($result->isQueueHaltedEarly()) {
                        return $this;
                    }

                    if ($callback !== null) {
                        call_user_func($callback, $result);
                    }

                    // Was the queue halted ?
                    if ($result->isQueueHalted()) {
                        return $this;
                    }
                } else {
                    if ($callback !== null) {
                        call_user_func($callback, $result);
                    }
                }
            }
        }
        if ($results) {
            return $results;
        }

        return false;
    }
853897
public function fire($event, $payload = [], $halt = false)
    {

        if ($this->filter && !call_user_func($this->filter, $event, $payload)) {
            return null;
        }

        if (!is_array($payload)) {
            $payload = [$payload];
        }

        $returnValues = [];

        foreach ($this->collectListeners($event, $payload) as $listener) {
            $returnValue = $this->callListener($listener, $event, $payload);

            if ($returnValue !== null && $halt) {
                return $returnValue;
            }

            if ($returnValue === false) {
                $returnValues[] = false;
                return $returnValues;
            }

            $returnValues[] = $returnValue;
        }

        return $returnValues;
    }
510136
public function fireEdit($id, $payload = [])
    {
        if (! method_exists($this, 'onEdit')) {
            return;
        }

        $payload = array_merge(['id' => $id], ['payload' => $payload]);

        $form = $this->app->call([$this, 'onEdit'], $payload);

        if ($form instanceof DisplayInterface) {
            $form->setModelClass($this->getClass());
        }

        if ($form instanceof Initializable) {
            $form->initialize();
        }

        if ($form instanceof FormInterface) {
            $form->setAction($this->getUpdateUrl($id));
            $form->setId($id);
        }

        return $form;
    }
1136768
public function trigger( $trigger, $params = [], $halt = false )
	{
		$keys = explode( '.', $trigger );
		$current = $this->triggers;
		$results = [];

		foreach ( $keys as $key )
		{
			$current = Arr::get( $current, $key );
			if ( !is_null( $current ) ) // && array_key_exists( '__hook_', $current ) )
			{
				foreach ( preg_grep_keys( "/__hook_[0-9]?/", $current ) as $hook )
				{
					if ( array_key_exists( $hook, $this->hooks ) )
					{
						$hook = $this->hooks[$hook];
						$result = BindingBuilder::call( $hook['callable'], is_array( $params ) ? $params : ['payload' => $params] );
						if ( !is_null( $result ) )
						{
							if ( $halt )
								return $result;
							else if ( is_array( $result ) )
								$results = array_merge_recursive( $results, $result );
							else
								$results[] = $result;
						}
					}
				}
			}
		}

		return $halt ? null : $results;
	}
473980
public function trigger($event, &$payload = null)
    {
        // Disallow calling a trigger on global hooks
        if ($event === '*') {
            return $this;
        }

        // Get all global hooks
        $globalHooks = [];
        if (isset($this->hooks['*']) && count($this->hooks['*']) > 0) {
            $globalHooks = $this->hooks['*'];
        }

        // Check if the event exists and has callables to run
        if (!isset($this->hooks[$event]) || count($this->hooks[$event]) === 0) {
            // There are no specific hooks, but maybe there's global hooks?
            if (count($globalHooks) === 0) {
                // There is nothing to do here
                return $this;
            }
            $hooks = $globalHooks;
        } else {
            $hooks = $this->hooks[$event];
            $hooks = array_merge($hooks, $globalHooks);
        }

        // All good, let's call those callables
        foreach ($hooks as $callable) {
            $callable($event, $payload);
        }
        return $this;
    }
595760
function fire(event, data) {
  var channel = require('cordova/channel');
  var cordova = require('cordova');
  var payload = {};

  channel.onCordovaReady.subscribe(function() {
    var prop = (event === 'error') ? event : 'data';
    payload[prop] = data;
    cordova.fireDocumentEvent(event, payload);
  });
}
478262
public function triggerEvent($event, Payload $payload): string
    {
        return $this->state($payload->state())->triggerEvent($event, $payload);
    }
841517
public function onSaving($event, $payload) {

        // Destructure params
        list($model) = $payload;

        // Check that the model supports uploads through Upchuck
        if (!$this->supportsUploads($model)
            || !($attributes = $model->getUploadAttributes())) return;

        // Loop through the all of the upload attributes ...
        event(new Events\HandlingSaving($model));
        foreach($attributes as $attribute) {

            // Check if there is an uploaded file in the upload attribute
            if (($file = $model->getAttribute($attribute))
                && is_a($file, UploadedFile::class)) {

                // Move the upload and get the new URL
                $url = $this->storage->moveUpload($file);
                $model->setUploadAttribute($attribute, $url);
            }

            // If the attribute field is dirty, delete the old file
            if ($model->isDirty($attribute)
                && !$this->keepsFilesOnDelete($model)
                && ($old = $model->getOriginal($attribute))) {
                $this->storage->delete($old);
            }
        }
        event(new Events\HandledSaving($model));
    }
998897
public function fireEvent($event)
    {
        $handle = $this->getQualifiedEvent($event);

        // Fire the event
        /** @var \League\Event\EventInterface $event */
        $event = $this->explainer->displayBelow(function () use ($handle) {
            return $this->events->emit($handle, [$this]);
        });

        // If the event returned a strict false, halt the task
        $wasHalted = $event && $event->isPropagationStopped();
        if ($wasHalted && $event !== 'halt' && method_exists($this, 'halt')) {
            $this->halt();
        }

        return !$wasHalted;
    }
868125
public function push($event, $payload = array())
	{
		$this->listen($event.'_pushed', function() use ($event, $payload)
		{
			$this->fire($event, $payload);
		});
	}