|<B>new (%hashcontent)B>||This is a convenience constructor. It will create a blessed hashreference initialized with %hashcontent.|
|<B>set_exception_cb ($cb)B>||If some event callback threw an exception then $cb is called with the exception as first argument.|
|<B>reg_cb ($eventname1, B>$cb1<B>, [$eventname2, B>$cb2<B>, ...])B>||
This method registers a callback $cb1 for the event with the
name $eventname1. You can also pass multiple of these eventname => callback
The return value will be an ID that represents the set of callbacks you have installed. Call unreg_cb with that ID to remove those callbacks again.
The callbacks will be called in an array context. If a callback doesnt want to return any value it should return an empty list. All results from the callbacks will be appended and returned by the event method.
For every event there are two other events emitted:
Before the callbacks for $eventname is being exectued the event "before_$eventname" is being emitted. And after the callbacks for $eventname have been run, the event "after_$eventname" is being emitted.
The "before_$eventname" callbacks allow you to stop the execution of all callbacks for the event $eventname and "after_$eventname". This can be used to intercept events and stop them.
If you give reg_cb a special argument called _while_referenced you can prevent callbacks from being executed once the reference in the second argument becomes undef. This works by converting the internal reference of the argument to _while_referenced to a weak reference and looking whether that reference becomes undef.
It works like this:
Whenever the disconnect event is emitted now and $window doesnt exist anymore the callback will be removed;
|<B>unreg_cb ($id)B>||Removes the set $id of registered callbacks. $id is the return value of a reg_cb call.|
|<B>event ($eventname, B>@args<B>)B>||
Emits the event $eventname and passes the arguments @args.
The return value is a list of defined return values from the event callbacks.
See also the specification of the before and after events in reg_cb above.
|<B>_event ($eventname, B>@args<B>)B>||This directly executes the event $eventname without executing callbacks of the before and after events (as specified in reg_cb above).|
|<B>unreg_meB>||If this method is called from a callback on the first argument to the callback (thats $self) the callback will be deleted after it is finished.|
|<B>stop_eventB>||When called in a before_ event callback then the execution of the event is stopped after all before_ callbacks have been run.|
|<B>add_forward ($obj, B>$forward_cb<B>)B>||
This method allows to forward or copy all events to an object.
$forward_cb will be called everytime an event is generated in $self.
The first argument to the callback $forward_cb will be $self, the second
will be $obj, the third will be the event name and the rest will be
the event arguments. (For third and rest of argument also see description
(Please note that it might be most useful to call _event in the callback to allow objects that receive the forwarded events to react better.)
|<B>remove_forward ($obj)B>||This method removes a forward. $obj must be the same object that was given add_forward as the $obj argument.|
|<B>remove_all_callbacksB>||This method removes all registered event callbacks and forwards from this object.|
|<B>events_as_string_dumpB>||This method returns a string dump of all registered event callbacks. This method is only for debugging purposes.|
Robin Redeker, <elmex at ta-sa.org>, JID: <elmex at jabber.org>
Copyright 2007 Robin Redeker, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
|perl v5.20.3||BS::EVENT (3)||2008-03-21|