Murat Ünalan > Class-Listener-0.01.04 > Class::Listener

Download:
Class-Listener-0.01.04.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.01.04   Source  

NAME ^

Class::Listener - executes methods on events

SYNOPSIS ^

  use Class::Listener;

  {
    package My::Listener;

    our @ISA = qw(Class::Listener);
        
        sub new 
        {
                bless [], 'My::Listener';
        }
        
        sub _on_event
        {
                print "event received";
        }       
  }

  my $l = My::Listener->new();

        # call '_on_event' method
        
  $l->Class::Listener::signal( 'event', @args );

DESCRIPTION ^

A base class which listenes for signals and runs methods.

METHODS

signal( $eventname, @args )

$eventname

A method with the name "_on_$eventname" will be called (if it exists).

@args

This array is forwarded to the callback.

[Note] signal returns the resulting return value of the callback.

EXPORT

None by default.

AUTHOR ^

Murat Uenalan, <muenalan@cpan.org>

SEE ALSO ^

Class::Proxy.

syntax highlighting: