Subject: | Suggestion about unreg_cb |
Hi!
I have started using AnyEvent::HTTPD and found one problem with $http-
Show quoted text
>unreg_cb. Perhaps, I've misunderstood about unreg_cb, but if we do
following:
$http->reg_cb("/my-url" => sub { ... });
I consider to remove this callback I need to do next:
$http->unreg_cb("/my-url");
But this does not work! So, I've attached Object::Event patch, which
may be useful for AnyEvent::HTTPD::HTTPServer, because it subclassing
Object::Event. Anyway, I will be glad to simplify process for removing
useless callbacks in any time and description of this action in
documentation.
Thanks.
Subject: | Object_Event_unreg_cb.diff |
--- /home/tvv/.staticperl-5.16.2/lib/Object/Event.pm.orig
+++ /home/tvv/.staticperl-5.16.2/lib/Object/Event.pm
@@ -352,6 +352,9 @@
for my $reg (values %$evs) {
@$reg = grep { (substr $_->[1], 0, $key_len) ne $key } @$reg;
}
+
+ # if remove by name do it easy
+ delete $evs->{$cb};
}
=item my $handled = $obj->event ($eventname, @args)