NAME
Reflex::Trait::Emitter - Emit an event when an attribute's value changes.
VERSION
version 0.004
SYNOPSIS
# 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,
);
DESCRIPTION
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.
event
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.
SEE ALSO
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