GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Mixin::Event::Dispatch::Event(3) User Contributed Perl Documentation Mixin::Event::Dispatch::Event(3)

Mixin::Event::Dispatch::Event - an event object

version 2.000

 my $self = shift;
 my $ev = Mixin::Event::Dispatch::Event->new(
   name => 'some_event',
   instance => $self,
 );
 $ev->dispatch;

Provides an object with which to interact with the current event.

Takes the following (named) parameters:
  • name - the name of this event
  • instance - the originating instance
  • parent - another Mixin::Event::Dispatch::Event object if we were invoked within an existing handler
  • handlers - the list of handlers for this event

We're assuming that time is of the essence, hence the peculiar implementation. Also note that this constructor is rarely called in practice - Mixin::Event::Dispatch uses bless directly.

Returns $self.

Returns the name of this event.

Returns true if this event has been deferred. This means another handler is active, and has allowed remaining handlers to take over the event - once those other handlers have finished the original handler will be resumed.

Returns true if this event has been stopped. This means no further handlers will be called.

Returns the original object instance upon which the "invoke_event" in Mixin::Event::Dispatch method was called.

This may be different from the instance we're currently handling, for cases of event delegation for example.

Returns the parent Mixin::Event::Dispatch::Event, if there was one. Usually there wasn't.

Returns a list of the remaining handlers for this event. Any that have already been called will be removed from this list.

Stop processing for this event. Prevents any further event handlers from being called.

Dispatches this event. Takes the parameters originally passed to "invoke_event" in Mixin::Event::Dispatch (with the exception of the event name), and passes it on to the defined handlers.

Returns $self.

Continue the current event. Do not use.

Semantics are subject to change so avoid this and consider "defer" instead. Currently does nothing anyway.

Returns $self.

Defers this event.

Causes remaining handlers to be called, and marks as "is_deferred".

 sub {
  my $ev = shift;
  print "Deferring\n";
  $ev->defer(@_);
  print "Finished deferring\n";
 }

Returns $self.

Unsubscribes the current handler from the event that we're processing at the moment.

Can be used to implement one-shot or limited-lifetime event handlers:

 my $count = 0;
 $obj->subscribeto_event(
   som_event => sub {
     my $ev = shift;
     return $ev->unsubscribe if ++$count > 3;
     print "Current count: $count\n";
   }
 );
 $obj->invoke_event('some_event') for 1..5;

Returns $self.

Show a debug message, should only be called if the appropriate (compile-time) flag is set:

 $self->debug_print(...) if DEBUG;

rather than expecting

 $self->debug_print(...);

to check for you.

Returns $self.

Tom Molesworth <cpan@perlsite.co.uk>

Copyright Tom Molesworth 2012-2014. Licensed under the same terms as Perl itself.
2015-09-14 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.