David,
Triggers are only fired when the entire value of the attribute is changed, pushing onto an
array does not meet this requirement.
What you want is to put an "after" method modifier on the push method, like so:
has 'foo' => (
traits => [ 'Array' ],
is => 'ro',
isa => 'ArrayRef[ Foo ]',
lazy => 1,
default => sub { [] },
handles => {
add_foo => 'push'
}
);
after 'foo' => sub {
my ($self, @foos) = @_;
if (@foos) {
# ... code you want to trigger here
}
}
- Stevan
On Thu Feb 18 22:18:20 2010, david.tulloh@AirservicesAustralia.com wrote:
Show quoted text> I would like to have an attribute with an Array trait providing the push
> method.
>
> I would also like to have a trigger function called whenever the
> attribute is modified.
>
> Both of these work independantly however modifying the attribute via the
> push method does not cause the trigger to be run.