|
NAMEMixin::Event::Dispatch::Event - an event objectVERSIONversion 2.000SYNOPSISmy $self = shift; my $ev = Mixin::Event::Dispatch::Event->new( name => 'some_event', instance => $self, ); $ev->dispatch; DESCRIPTIONProvides an object with which to interact with the current event.METHODSnewTakes the following (named) parameters:
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. READ-ONLY ACCESSORSnameReturns the name of this event.is_deferredReturns 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.is_stoppedReturns true if this event has been stopped. This means no further handlers will be called.instanceReturns 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. parentReturns the parent Mixin::Event::Dispatch::Event, if there was one. Usually there wasn't.handlersReturns a list of the remaining handlers for this event. Any that have already been called will be removed from this list.stopStop processing for this event. Prevents any further event handlers from being called.dispatchDispatches 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. playContinue the current event. Do not use.Semantics are subject to change so avoid this and consider "defer" instead. Currently does nothing anyway. Returns $self. deferDefers 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. unsubscribeUnsubscribes 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. debug_printShow 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. AUTHORTom Molesworth <cpan@perlsite.co.uk>LICENSECopyright Tom Molesworth 2012-2014. Licensed under the same terms as Perl itself.
Visit the GSP FreeBSD Man Page Interface. |