The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Beam::Listener

VERSION

version 1.007

SYNOPSIS

  package MyListener;

  extends 'Beam::Listener';


  # add metadata with subscription time
  has sub_time => is ( 'ro',
                        init_arg => undef,
                        default => sub { time() },
  );

   # My::Emitter consumes the Beam::Emitter role
   my $emitter = My::Emitter->new;
   $emitter->on( "foo", sub {
        my ( $event ) = @_;
        print "Foo happened!\n";
        # stop this event from continuing
        $event->stop;
    },
    class => MyListener
    );

DESCRIPTION

This is the base class used by Beam::Emitter objects to store information about listeners. Create a subclass to add data attributes.

ATTRIBUTES

code

A coderef which will be invoked when the event is distributed.

SEE ALSO

Beam::Emitter

AUTHOR

Doug Bell <preaction@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2016 by Doug Bell.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.