| 1 | package Evo::Promise::AE; | ||
| 2 | use Evo '-Class; -Export *'; | ||
| 3 | |||
| 4 | BEGIN { | ||
| 5 | eval { require AE; 1 } or die "Install AnyEvent to use this module"; | ||
| 6 | } | ||
| 7 | with '-Promise::Role'; | ||
| 8 | |||
| 9 | sub postpone ($me, $sub) { | ||
| 10 | &AE::postpone($sub); | ||
| 11 | } | ||
| 12 | |||
| 13 | foreach my $fn (qw(promise deferred resolve reject race all)) { | ||
| 14 | export_code $fn , sub { | ||
| 15 | __PACKAGE__->$fn(@_); | ||
| 16 | }; | ||
| 17 | } | ||
| 18 | |||
| 19 | 1; | ||
| 20 | |||
| 21 | __END__ |