Mixin::Event::Dispatch::Bus - a message bus
version 2.000
{ package Some::Class; sub bus { shift->{bus} ||= Mixin::Event::Dispatch::Bus->new } } my $obj = bless {}, 'Some::Class'; $obj->bus->subscribe_to_event( something => sub { my ($ev) = @_; warn "something!" } ); $obj->bus->invoke_event('something');
This class uses Mixin::Event::Dispatch to provide a message bus - instantiate this and call the usual methods to deal with events:
"subscribe_to_event" in Mixin::Event::Dispatch
"invoke_event" in Mixin::Event::Dispatch
This allows several classes to share a common message bus, or to avoid polluting a class with event-related methods.
add_handler_for_event, clear_event_handlers, event_handlers, invoke_event, subscribe_to_event, unsubscribe_from_event
Tom Molesworth <cpan@perlsite.co.uk>
Copyright Tom Molesworth 2014. Licensed under the same terms as Perl itself.
To install Mixin::Event::Dispatch, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mixin::Event::Dispatch
CPAN shell
perl -MCPAN -e shell install Mixin::Event::Dispatch
For more information on module installation, please visit the detailed CPAN module installation guide.