Skip to content

Instantly share code, notes, and snippets.

@wchristian
Last active August 27, 2022 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wchristian/1978b0e69d5bd1f4efb5c3623e0588a1 to your computer and use it in GitHub Desktop.
Save wchristian/1978b0e69d5bd1f4efb5c3623e0588a1 to your computer and use it in GitHub Desktop.
use strictures 2;
use 5.012;
use Future;
sub async_task {
Future
->done
->then( sub {
return "meep";
} )
->then( sub {
say @_;
die if .5 > rand;
return "marp";
} )
->then( sub {
say @_;
return "end\n";
} );
}
sub wrap_in_catch {
shift->else( sub { "fail\n" } );
}
say wrap_in_catch(async_task)->get for 1 .. 10;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment