I’m just encountering Mojo::AsyncAwait and notice that it lists Coro as a 
dependency.

Isn’t Coro problematic in newer Perls? I thought Marc had basically written off 
support for 5.22 onward.

-F


> On Jan 10, 2020, at 8:49 AM, 'Tobias Oetiker' via Mojolicious 
> <[email protected]> wrote:
> 
> I just read Joel's blog 
> (https://mojolicious.io/blog/2018/12/24/async-await-the-mojo-way/) about 
> async/await support. This is wonderful. I am totally excited about this. 
> Thank you to all involved!
> 
> Obviously I had to test this right away and it works great with the 
> Mojolicious::Lite demo shown in the blog. 
> 
> But how do I specify a route to a async method in a controller for a 
> Mojolicious app?
> 
> Using a callback I can easily translate the Lite approach
> 
> $r->get('/cb' => async sub ($c) {
>     await Mojo::Promise->new(sub ($resolve,$fail) {
>       Mojo::IOLoop->timer(3 => sub { 
>           $resolve->();
>       });
>     });
>     $c->render(text => 'hello');
> });
> 
> but how do I use this when I want to have the code in a controller:
> 
> $r->get('/ctr')->to('example#hello');
> 
> with
> 
> package MyApp::Controller::Example;
> use Mojo::Base 'Mojolicious::Controller', -async, -signatures;
> 
> async sub welcome ($self) {
>   await Mojo::Promise->new(sub ($resolve,$fail) {
>       Mojo::IOLoop->timer(3 => sub { 
>           $resolve->();
>       });
>   });
>   $self->render(text => 'hello');
> }
> 
> does not work as expected as the router does not seem to expect the methods 
> to be async when called like that.
> 
> 
> -- 
> 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 view this discussion on the web visit 
> https://groups.google.com/d/msgid/mojolicious/519ec59d-cb9d-46c6-9a6a-970a2f3142b6%40googlegroups.com.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/mojolicious/DDE13127-6F00-48CF-A5EF-DB91849080B5%40felipegasper.com.

Reply via email to