My concern is that the EventInterface is much heavier then it needs to be. 
Just some of my thoughts on it:

There's really no need for the event to know what it's being called by 
anyone. The code that triggers the event names it, the listeners know which 
ones they want to attach to, and the Manager makes it happen. To make it 
easier for the listeners you have the name as a parameter to the callback 
so you can have a single callback method if you choose and route the 
handling internally if you want. This makes the event name immutable by 
default. If one of the listens what to format the context after doing 
something with it they just trigger their own event.

I don't really understand why it has setter/getter for any parameters 
either as anything you'd use them for should be part of the context.

The idea of have a standard way to access the context is great but 
misplaced IMHO. Just look as Docblock from getContext() ```@return 
null|string|object```
You might as well just used mixed at that point. The reason this is 
happening is anything about the context/payload of the message is going to 
be depend total on the domain it's used in for what is returned. once again 
the code triggering the event determines what this is and the attached 
listeners need to know how to work with it. We've all seen this before you 
need an interface here which probably already exist or should be defined. 
Something like MyAppEventInterface extends EventInterface comes to mind for 
me. That insures it can be past to the trigger() and the attach listeners 
can use either interface on the parameter in their callback as they need.

So with this changes the EventInterface becomes very simply and easy to 
implement:
```php

namespace Psr\EventManager;/** * Representation of an event */interface 
EventInterface{
    /**     * Indicate whether or not to stop propagating this event     *     
* @param  bool $flag     */    public function stopPropagation($flag);    /**   
  * Has this event indicated event propagation should stop?     *     * @return 
bool     */    public function isPropagationStopped();}
```

I use something very similar in my own event system I developed just with a 
little different names for methods etc.
PHP Event Mediator 
<http://www.phpclasses.org/package/9568-PHP-Emit-and-listen-to-events-using-a-mediator-object.html>
 

-- 
You received this message because you are subscribed to the Google Groups "PHP 
Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/php-fig/325f42ff-ed26-4f18-bd6f-b2aa0d7208f3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to