Closed pipcet closed 6 years ago
Oops, messed up the example.
#!/usr/bin/env perl
use utf8;
use Mojolicious::Lite;
use Mojo::Pg;
use Mojo::Pg::PubSub;
helper pg => sub {
state $pg = Mojo::Pg->new('postgresql://pip@%2fvar%2frun%2fpostgresql:5433/mojolicious');
$pg;
};
get '/test' => sub {
my $c = shift;
my $pg = $c->pg;
my $db = $pg->db;
my $pubsub = $pg->pubsub;
my $cb;
$cb = sub {
my $pubsub = shift;
warn;
$pubsub->unlisten(test => $cb);
};
$pubsub->listen(test => $cb);
$pubsub->listen(test => sub { warn; });
$pubsub->notify(test =>);
};
app->start;
Expected behavior: two warnings. Actual behavior: a single warning. Fixed by PR.
Steps to reproduce the behavior
Register two different callbacks for the same notification, the first of which calls
$pubsub->unlisten($chan, $cb)
in the notification handler.Expected behavior
Both callbacks should be called. (That's what I expected. There's no note in the documentation that callbacks mustn't call
->unlisten
.)Actual behavior
Only the first callback is called.
It modifies
@{$pubsub->{chans}{$chan}}
, which confuses thefor
loop inMojo::Pg::PubSub::_db
.PR forthcoming.