Reflex::Trait::Observed - Automatically watch Reflex objects.
version 0.060
# Not a complete program. This example comes from Reflex's main # synopsis.
has clock => ( isa => 'Reflex::Interval', is => 'rw', traits => [ 'Reflex::Trait::Observed' ], setup => { interval => 1, auto_repeat => 1 }, );
Reflex::Trait::Observed modifies a member to automatically observe any Reflex::Base object stored within it. In the SYNOPSIS, storing a Reflex::Interval in the clock() attribute allows the owner to watch the timer's events.
This trait is a bit of Moose-based syntactic sugar for Reflex::Base's more explict watch() and watch_role() methods.
The "setup" option provides default constructor parameters for the attribute. In the above example, clock() will by default contain
Reflex::Interval->new(interval => 1, auto_repeat => 1);
In other words, it will emit the Reflex::Interval event ("tick") once per second until destroyed.
Attribute events are mapped to the owner's methods using Reflex's role-based callback convention. For example, Reflex will look for an on_clock_tick() method to handle "tick" events from an object with the 'clock" role.
The "role" option allows roles to be set or overridden. A watcher attribute's name is its default role.
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::EmitsOnChange
"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.