On 06/29/2014 12:43 AM, Bogdan Katyński wrote:
Hi.
I am trying to use find_one in non blocking mode. I am calling it from a
Mojo::IOLoop->delay
When I find a doc, in the callback function, I call the $delay->begin->()
passed.
But when there's no doc found, no callback is called at all so I cannot
signal that the operation has finished.
How to register a callback for a situation that no docs are found?
Thanks,
Bogdan
my $end = $delay->begin;
$mango->db('foo')->collection('bar')->find_one({ ... } => sub {
my ($coll, $err, $doc) = (@_);
$end->($doc);
});
Is the proper way to handle it - then in your delay sub...
my $delay = Mojo::IOLoop->delay(sub {
my ($delay, @docs) = (@_);
# strip any undef values from @docs
....
}
--
You received this message because you are subscribed to the Google Groups
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.