# from Mattia Barbon # on Sunday 13 June 2010 01:28: > subscribe( $sender, 'SignalName', $object, 'MethodName' ); > subscribe( $sender, 'SignalName', \&_function );
Could this be a method? $sender->subscribe(SignalName => $object, 'MethodName'); $sender->subscribe(SignalName => sub {...}); Also, maybe a way to unsubscribe from all of the subscriptions $sender->unsubscribe('SignalName'); and perhaps a way to get at "what is subscribed" without having to reconstruct the signatures (e.g. still in scope, etc.) foreach my $sig ($sender->subscriptions('SignalName')) { $sender->unsubscribe(SignalName => $sig) if some_condition($sig); } Where $sig might be a string of "$object_identifier|MethodName" or something like that. In general, this doesn't look very similar to signals/slots (which is probably a good thing.) The Qt signals/slots model is miserably polluted with notions of alternate type signatures for the slots and feels like bashing my head against a wall of C++ to work around the compile-time type signature checking. What you have proposed may be better named "pub/sub" -- except I don't see a publish API here. --Eric -- To a database person, every nail looks like a thumb. --Jamie Zawinski --------------------------------------------------- http://scratchcomputing.com ---------------------------------------------------