Hello, Moose dudes!

I’ve written a module that somebody might find useful: MooseX::OmniTrigger.

=head1 DESCRIPTION

Sometimes you want to know when your attributes' values change. No matter when! 
No matter how!

MooseX::OmniTrigger is an effort to provide Moose attributes with triggers that 
may to some folks behave more DWIMmily than standard Moose triggers, working 
around the documented feature/bug/caveat, "Triggers will only fire when you 
assign to the attribute, either in the constructor, or using the writer. 
Default and built values will not cause the trigger to be fired."

An omnitrigger fires any time its attribute's value is initialized, set, or 
cleared. This includes initialization with default and built values, lazy or 
no, and sets via native type accessors.

The callback is given as a subref, and receives four arguments: the object, the 
attribute name, the new value, and the old value. The new and old values are 
given as array refs. An empty array indicates *no* value -- the slot is 
uninitialized or has been cleared. Otherwise, the value will be the first (and 
only) array element.

Omnitriggers are recursion-proof. Firings beyond the first of a particular 
omnitrigger in the same call stack are quietly prevented.

=cut

So far as I’ve been able to find, there currently aren’t any other modules like 
this one, so I’d like to make it available on the CPAN. But first I’d like your 
feedback, if you’ve got the time to give it.

https://github.com/trlorenz/MooseX-OmniTrigger


Best regards,

Todd Lorenz

Reply via email to