The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

MooseX::Callbacks - Add ability to register and call callbacks with a role.

VERSION

Version 0.01

SYNOPSIS

  package Foo;
  use Moose;
  with 'MooseX::Callbacks';

  ...

  my $foo = Foo->new;
  $foo->register_callbacks(ding => \&dong);
  $foo->dispatch('ding', $arg1, $arg2...);

ATTRIBUTES

_callbacks

Hashref of arrayrefs of callbacks. Delegates via native traits set_callbacks, get_callbacks, clear_callbacks, has_callbacks

METHODS

register_callback($event => \&callback)

Same as register_callbacks

register_callbacks(event1 => \&callback[, event2 => \&callback2 ...])

Registers callbacks for given events. Should be coderefs.

dispatch($event, @args)

Calls callbacks for $event with @args as parameters.

TODO

Ability to unregister callbacks.

AUTHOR

Mischa Spiegelmock, <revmischa at cpan.org>

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc MooseX::Callbacks

ACKNOWLEDGEMENTS

Nobody.

LICENSE AND COPYRIGHT

Copyright 2012 Mischa Spiegelmock.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.