Event.php
function emit($dataMerge = null, $meeter = null)
    {
        # Prepare given arguments:
        if ($dataMerge instanceof iMeeter) {
            $meeter = $dataMerge;
            $dataMerge = null;
        }

        $Event     = clone $this;
        $Collector = $Event->collector();
        if ($dataMerge !== null)
            ## build collector with default data
            ## we have to keep defaults untouched
            $Collector->import($dataMerge);

        if ($meeter === null)
            $meeter = $this->_getMeeter();


        # Emit listeners:
        $this->_tmp__isEmiting = true;

        $result = null;
        /** @var iListener $listener */
        foreach(clone $this->_listenerQueue() as $listener)
        {
            # propagation stopped by listener
            if ( $Event->isStopPropagation() )
                break;


            $this->_c_lastEmitted = $listener;

            /** @var iMeeter $meeter */
            $meeter = clone $meeter; // reset meter to execute new listener
            $meeter->setEventBelong($Event);

            try {
                $result = $meeter->invokeListener($listener, $Collector);
            } catch(\Exception $e) {
                if ($this->failure)
                    return call_user_func($this->failure, $e, $Event);
                
                throw $e;
            }

            if ($result !== null) {
                if (is_array($result) || $result instanceof \Traversable)
                    ## set result into collector
                    $Collector->import($result);

                // TODO determine result to merge with Collector \
                //      or store in collector with listener name.  
            }
        }

        $this->_tmp__isEmiting = false;
        return $Event;
    }
function emit($dataMerge = null, $meeter = null)
    {
        # Prepare given arguments:
        if ($dataMerge instanceof iMeeter) {
            $meeter = $dataMerge;
            $dataMerge = null;
        }

        $Event     = clone $this;
        $Collector = $Event->collector();
        if ($dataMerge !== null)
            ## build collector with default data
            ## we have to keep defaults untouched
            $Collector->import($dataMerge);

        if ($meeter === null)
            $meeter = $this->_getMeeter();


        # Emit listeners:
        $this->_tmp__isEmiting = true;

        $result = null;
        /** @var iListener $listener */
        foreach(clone $this->_listenerQueue() as $listener)
        {
            # propagation stopped by listener
            if ( $Event->isStopPropagation() )
                break;


            $this->_c_lastEmitted = $listener;

            /** @var iMeeter $meeter */
            $meeter = clone $meeter; // reset meter to execute new listener
            $meeter->setEventBelong($Event);

            try {
                $result = $meeter->invokeListener($listener, $Collector);
            } catch(\Exception $e) {
                if ($this->failure)
                    return call_user_func($this->failure, $e, $Event);
                
                throw $e;
            }

            if ($result !== null) {
                if (is_array($result) || $result instanceof \Traversable)
                    ## set result into collector
                    $Collector->import($result);

                // TODO determine result to merge with Collector \
                //      or store in collector with listener name.  
            }
        }

        $this->_tmp__isEmiting = false;
        return $Event;
    }
function emit ( $ dataMerge = null , $ meeter = null ) { # Prepare given arguments: if ( $ dataMerge instanceof iMeeter ) { $ meeter = $ dataMerge ; $ dataMerge = null ; } $ Event = clone $ this ; $ Collector = $ Event -> collector ( ) ; if ( $ dataMerge !== null ) ## build collector with default data ## we have to keep defaults untouched $ Collector -> import ( $ dataMerge ) ; if ( $ meeter === null ) $ meeter = $ this -> _getMeeter ( ) ; # Emit listeners: $ this -> _tmp__isEmiting = true ; $ result = null ; /** @var iListener $listener */ foreach ( clone $ this -> _listenerQueue ( ) as $ listener ) { # propagation stopped by listener if ( $ Event -> isStopPropagation ( ) ) break ; $ this -> _c_lastEmitted = $ listener ; /** @var iMeeter $meeter */ $ meeter = clone $ meeter ; // reset meter to execute new listener $ meeter -> setEventBelong ( $ Event ) ; try { $ result = $ meeter -> invokeListener ( $ listener , $ Collector ) ; } catch ( \ Exception $ e ) { if ( $ this -> failure ) return call_user_func ( $ this -> failure , $ e , $ Event ) ; throw $ e ; } if ( $ result !== null ) { if ( is_array ( $ result ) || $ result instanceof \ Traversable ) ## set result into collector $ Collector -> import ( $ result ) ; // TODO determine result to merge with Collector \ //      or store in collector with listener name.   } } $ this -> _tmp__isEmiting = false ; return $ Event ; }
Trigger Listeners Within Events

- reset propagation value
- iterate over listeners priority and fire actions
- readable props of this event can resolved as listener
arguments.
- this event can be resolved to listener as $e or $event __invoke($e)
- implement to know last emitted listener

note: collecting listeners results can implemented with meeter watch
note: each event after emit has collected of data result in Emitter
Collector. if you want it can be merged with event collector.
$results = $emitter->collector()
$emitter->event()->collector()->from($result)

@param array|\Traversable|iMeeter $dataMerge
@param iMeeter|null $meeter

@return iEvent Clone/Copy of self
@throws \Exception
Trigger Listeners Within Events