Mojo::Promise::Role::Any - Fulfill with the first fulfilled promise
use Mojo::Promise; my $any_promise = Mojo::Promise ->with_roles( '+Any' ) ->any( @promises );
Make a new promise that fulfills with the first fulfilled promise, and rejects otherwise. The result is a flat list of the arguments for the fulfilled promise (and not an anonymous array of values).
This should be the Perl expression of the same idea in bluebirdjs (http://bluebirdjs.com/docs/api/promise.any.html).
This is handy, for instance, for asking for several servers to provide the same resource and taking the first one that responds.
Takes a lists of promises (or thenables) and returns another promise that fulfills when any promise fulfills (and it ignores the others after that).
If none of the promises fulfill, the any promise rejects.
If you pass no promises, the any promise rejects.
Mojolicious, Mojo::Promise, Role::Tiny
http://bluebirdjs.com/docs/api/promise.any.html
This source is in Github:
https://github.com/briandfoy/mojo-promise-role-higherorder
brian d foy, <bdfoy@cpan.org>
<bdfoy@cpan.org>
Copyright © 2018-2021, brian d foy, All Rights Reserved.
You may redistribute this under the terms of the Artistic License 2.0.
To install Mojo::Promise::Role::HigherOrder, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojo::Promise::Role::HigherOrder
CPAN shell
perl -MCPAN -e shell install Mojo::Promise::Role::HigherOrder
For more information on module installation, please visit the detailed CPAN module installation guide.