Padre::Role::PubSub(3) A simple event publish/subscriber role

DESCRIPTION

This class allows the addition of simple publish/subscribe behaviour to an arbitrary class.

METHODS

subscribe

  $publisher->subscriber( $object, {
      my_event_one => 'my_handler_method',
      my_event_two => 'my_handler_method',
  } );

The <subscriber> method lets you register an object for callbacks to a particular set of method for various named events.

Returns true, or throws an exception if any of the parameters are invalid.

unsubscribe

  $publisher->unsubscribe($subscriber);

The "unsubscribe" method removes all event registrations for a particular object.

Returns true.

publish

  $publisher->publish("my_event_one", "param1", "param2");

The "publish" method is called on the published to emit a particular named event.

It calls any registered event handlers in sequence, ignoring exceptions.

Returns true, or throws an exception if the event name is invalid.

COPYRIGHT & LICENSE

Copyright 2008-2013 The Padre development team as listed in Padre.pm.

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

The full text of the license can be found in the LICENSE file included with this module.