Reflex::Trait::Emitter - Emit an event when an attribute's value changes.
version 0.011
# Not a complete program. See examples eg-09-emitter-trait.pl # and eg-10-setup.pl for working examples. package Counter; use Moose; extends 'Reflex::Object'; use Reflex::Trait::Emitter; has count => ( traits => ['Reflex::Trait::Emitter'], isa => 'Int', is => 'rw', default => 0, );
An attribute with the Reflex::Trait::Emitter trait emit an event on behalf of its object whenever its value changes. The event will be named after the attribute by default. It will be accompanied by a "value" parameter, the value of which is the attribute's new value at the time of the change.
In the SYNOPSIS example, changes to count() cause its Counter object to emit "count" events.
The "default" option can be used to override the default event emitted by the Reflex::Trait::Emitter trait. That default, by the way, is the name of the attribute.
The "setup" option provides default constructor parameters for the attribute. In the above example, clock() will by default contain
Reflex::Timer->new(interval => 1, auto_repeat => 1);
In other words, it will emit the Reflex::Timer event ("tick") once per second until destroyed.
The "setup" option is a work-around for unfortunate default timing. It will be deprecated if default can be made to work instead.
Reflex Reflex::Trait::Observer
"ACKNOWLEDGEMENTS" in Reflex "ASSISTANCE" in Reflex "AUTHORS" in Reflex "BUGS" in Reflex "BUGS" in Reflex "CONTRIBUTORS" in Reflex "COPYRIGHT" in Reflex "LICENSE" in Reflex "TODO" in Reflex
To install Reflex, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Reflex
CPAN shell
perl -MCPAN -e shell install Reflex
For more information on module installation, please visit the detailed CPAN module installation guide.