Synopsis
use Promise::Syntax;
my $result_promise = async
await { v1 => promise1() },
await { v2 => promise2( $_->{v1} ) },
await { _ => log_promise( "acquired values: ".join( ', ', @$_{ qw(v1 v2) } ) ) },
as { $_->{v1} + $_->{v2} }; # Value that will be returned by the $result_promise
Description
This is a 'bicycle' i use for some time in my system tests.
Comments
https://en.wikipedia.org/wiki/Async/await#In_Perl_5
https://metacpan.org/pod/Future::AsyncAwait
However, Future::AsyncAwait hooks deeply into Perl interpreter and requires loading compiled code which is not acceptable for some environments.
Promise::Syntax is implemented pure Perl without source filters and other similar features.
Essentially, it only simplifies ->then( sub { ... } ) chains.
No support for "try { ... } catch { ... }" is planned (which should be present in a good async/await implementation).
Please sign up to post a review.