Promise::Tiny - A promise implementation written in Perl
use Promise::Tiny; my $promise = Promise::Tiny->new(sub { my ($resolve, $reject) = @_; some_async_process(..., sub { # callback. ... if ($error) { $reject->($error); } else { $resolve->('success value'); } }); })->then(sub { my ($value) = @_; print $value # -> success value }, sub { my ($error) = @_; # handle error });
Promise::Tiny is tiny promise implementation. Promise::Tiny has same interfaces as ES6 Promise.
Copyright (C) hatz48.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
hatz48 <hatz48@hatena.ne.jp>
To install Promise::Tiny, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Promise::Tiny
CPAN shell
perl -MCPAN -e shell install Promise::Tiny
For more information on module installation, please visit the detailed CPAN module installation guide.