AnyEvent-Promises
view release on metacpan or search on metacpan
lib/AnyEvent/Promises.pm view on Meta::CPAN
otherwise it is an equivalent to:
my $d = deferred();
$d->resolve($arg);
$d->promise;
=item C<is_promise($arg)>
Returns true if the argument is a promise (object with method C<then>).
=back
=head1 SEE ALSO
=over 4
=item L<AnyEvent>
To use this module it is necessary to have basic understanding of L<AnyEvent> event loop.
=item L<Promises>
Although L<AnyEvent::Promises> is similar to L<Promises>
(and you can use its more thorough documentation to understand the concept of promises)
there are important differences.
AnyEvent::Promises does not work without running event loop
based on L<AnyEvent>. All C<$on_fulfilled>, C<$on_rejected> handlers
(arguments of C<then> method) are run in "next tick" of event loop
as is required in 2.2.4 of the promises spec L<< http://promises-aplus.github.io/promises-spec/#point-39 >>.
There is also a crucial difference in C<$on_reject> handler behaviour
(exception handling). Look at
my $d = deferred();
$d->reject($reason);
my $p = $d->promise->then(
sub { },
sub {
return @_;
}
);
$p->then(
sub {
warn "Code here is called when using AnyEvent::Promises";
},
sub {
warn "Code here is called when using Promises";
}
);
With C<Promises> the C<$p> promise is finally rejected with C<$reason>,
while with C<AnyEvent::Promises> the C<$promise> is finally fulfilled
with C<$reason>, because the exception was handled (the handler did not
throw an exception).
=item L<https://github.com/kriskowal/q/wiki/API-Reference>
Here I shamelessly copied the ideas from.
=back
=head1 AUTHOR
Roman Daniel <roman.daniel@davosro.cz>
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2014 by Roman Daniel.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
( run in 0.938 second using v1.01-cache-2.11-cpan-acf6aa7dc9e )