[PEPr] Comment on RFC::NotificationCenter
| From: | Alan Knowles | Date: | Mon, 03 Jan 2005 02:34:45 +0000 |
| Subject: | [PEPr] Comment on RFC::NotificationCenter | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-35309@lists.php.net to get a copy of this message | ||
Alan Knowles (http://pear.php.net/user/alan_k) has commented on the proposal for
RFC::NotificationCenter.
Comment:
My original thoughts where that emulating gobjects signal model may be an
idea.
eg. signal::connect($obj,'signame',$callback,$args...);
signal::register('class','signame');
signal::emit($obj, 'eventname',$args);
But the more I look at it, something that follows W3C events API may be
more familar.
Event::register('classname','event');
Event::addListener($obj, 'event', $callback, $args);
Event::removeListener($obj, 'event',$callback);
Event::emit($obj|classname, 'event',$args);
you could then wrap these in your own class:
function addEventLister('event',$callback,$args) {
Event::addListener($this, 'event', $callback, $args);
}
Without resorting to a yourclass extends Event, however it's a little
complex implement object instance listeners using a vistor pattern (as
it's difficult to get object instance ID's from the registered instance
AFAIR)
Ideally all this would be done by PHP internals (using an Event Interface)
- in a similar way to Iterators..
Proposal information:
http://pear.php.net/pepr/pepr-proposal-show.php?id=186
--
Sent by PEPr, the automatic proposal system at http://pear.php.net