uperl / AnyEvent-FTP

2 stars 2 forks source link

call back as as last argument to method #15

Closed plicease closed 10 years ago

plicease commented 11 years ago

I keep thinking it would be good to be able to do

$client->cwd('/foo', sub{ ... });

as an alternative to

$client->cwd('/foo')->cb(sub { ... });

but for now, I don't think I will implement this. Although it saves some typing, the added complexity to the implementation doesn't seem t justify it, since it doesn't actually allow you to do something that you can't already do.

If this were Mojolicious, then the first form could be a blocking command, ie. equivalent to this:

my $cv = $client->cwd('/foo');
$cv->recv;
sub { ... }->(); # though you probably wouldn't write it this way.

but calling recv before a message is available is discouraged in AE land since it isn't supported by all of the evet loops.