NAME
UR::Observer - bind callbacks to object changes
SYNOPSIS
$rocket = Acme::Rocket->create(
fuel_level => 100
);
$observer = $rocket->add_observer(
aspect => 'fuel_level',
callback =>
sub {
print "fuel level is: " . shift->fuel_level . "\n"
},
);
for (3 .. 0) {
$rocket->fuel_level($_);
}
# fuel level is: 3
# fuel level is: 2
# fuel level is: 1
# fuel level is: 0
$observer->delete;