Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Object destruction notification

by lachoy (Parson)
on Jun 26, 2002 at 09:59 UTC ( [id://177347]=note: print w/replies, xml ) Need Help??


in reply to Object destruction notification

If you have control over the first object, you can use Class::Observable:

package FirstObject; use base qw( Class::Observable ); ... sub DESTROY { my ( $self ) = @_; $self->notify_observers( 'DESTROY' ); } package SecondObject; sub take_first_object { my ( $class, $first_object ) = @_; $first_object->add_observer( $class ); } sub update { my ( $class, $first_object, $type ) = @_; return unless ( $type eq 'DESTROY' ); ... do stuff with $first_object ... }

If you don't have control over the first object and it's well designed, maybe you could subclass it to add the Observable behavior.

Chris
M-x auto-bs-mode

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://177347]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-25 13:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found