Plans: New module for event registering and raising.

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Hi Guys,

I'm about to start work on what should (initially) be a fairly simple
API for allowing modules to register for events within an application. I
think it's best explained with a simple code example, based on the
intended use for this application.

I haven't worked out all the details on this, including how each plug in
will pass back information on why it was unsuccessful, but that should
give you a general idea of my plan.

So, I have a couple of questions:

1. Does anyone know of a package on CPAN that does something similar to
this already?

2. Has anyone considered working on something similar in the past,
and/or have anything they'd like to contribute?

3. (last, but least) any suggestions on the namespace that this would
fall under?

Look forward to your replies :)


package Account::Event::Business;
use Account::Event;

Account::Event->register('ACCOUNT_CLOSE', &closeAccount );

sub closeAccount {
    my ($account) = @_;
    if ($account->someproperty eq 'somevalue') {
        return 0; # Not allowed to close
    return 1; # Didn't fail any checks in this plugin

package Account;
use Account::Event;

sub close {
    my ($self) = @_;
    $self->active(0); # For example;
    if (! Account::Event->raise('ACCOUNT_CLOSE')) {
        die "Can't close account";
    } else {


Re: Plans: New module for event registering and raising.

Never mind, the helpful lads in #Catalyst have pointed me towards
Class::Publisher :)

Lee Standen wrote:
Quoted text here. Click to load it

Site Timeline