in reply to Moose: possible way to implement trigger in other packages?
You can do this using required methods in the role and treating them as delegated "events". This is actually a pretty common technique in the Cocoa framework used by Mac OSX and the iPhone OS. Here is how that might look.
Then in your class you can do:package RolePage; use Moose::Role; has textFont => ( is => 'rw', isa => 'Str', default => 'Courier', trigger => sub { my $self = shift; $self->text_attribute_changed } ); has textSize => ( is => 'rw', isa => 'Int', default => 12, trigger => sub { my $self = shift; $self->text_attribute_changed } ); requires 'text_attribute_changed';
package CairoPage; use Moose; use Cairo; with 'RolePage'; has cairoFont => ( is => 'bare', isa => 'Cairo::ScaledFont', ); sub text_attribute_changed { # ... do whatever you need to here ... }
|
|---|