AnyEve...:Event(3pm)
πΈ AnyEvent::FTP::Role::Event π
okay bestie, welcome to the perl manual page for AnyEvent::FTP::Role::Event β that's a 3pm section page living in the User Contributed Perl Documentation, and it's genuinely so useful, no cap.
β¨ NAME β¨
AnyEvent::FTP::Role::Event β literally the event interface for AnyEvent::FTP objects π¦
π VERSION π
version 0.20 β she's grown, she's thriving β¨
π§ SYNOPSIS π§
here's the whole vibe. first you make a class and pull in the role:
package AnyEvent::FTP::Foo;
use Moo;
with 'AnyEvent::FTP::Role::Event';
__PACKAGE__->define_events(qw( error good ));
sub some_method
{
my($self) = @_;
if($self->other_method)
{
$self->emit(good => 'paylod message');
}
else
{
$self->emit(error => 'something went wrong!');
}
}
then, later on somewhere else, you actually listen for the events:
use AnyEvent::FTP::Foo;
my $foo = AnyEvent::FTP::Foo->new;
$foo->on_good(sub {
my($message) = @_;
print "worked: $message";
});
$foo->on_error(sub {
my($message) = @_;
print "failed: $message";
});
$foo->some_method
see how it's giving main character energy? define the events once, flex them anywhere π
π DESCRIPTION π
so this role hands every class in AnyEvent::FTP the same uniform event callback mechanism, which is honestly iconic of her. π«Ά
you declare your events with the define_events method. once they're declared, you get on_event_name to attach a callback to a particular event, and emit to actually trigger those callbacks. it's a whole little ecosystem and i'm obsessed π
π METHODS π
π« define_events
__PACKAGE__->define_events( @list_of_event_names );
you call this inside the class package to declare the event names for every event the class is gonna use. in return it makes methods shaped like on_event_name, which are exactly the ones you use to add callbacks to events. slay β¨
π« emit
$obj->emit($event_name, @arguments);
this calls the callbacks that are associated with the $event_name you pass in. and it passes your @arguments straight along to that callback. no middleman nonsense, just direct delivery π¬
π SEE ALSO π
- AnyEvent::FTP β the parent vibe, go read her too π
π AUTHOR π
Author: Graham Ollis <plicease@cpan.org>
Contributors:
- Ryo Okamoto
- Shlomi Fish
- JosΓ© JoaquΓn Atria
πΈ COPYRIGHT AND LICENSE πΈ
This software is copyright (c) 2017-2022 by Graham Ollis.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. π
ngl none of this would exist without Graham Ollis and the contributors β legends only π
and that's a wrap, bestie!! this page came from perl v5.40.1 and was dated 2026-02-16, so go forth and emit responsibly β¨ππ¦ periodt
π¦ where this page comes from
- ubuntu stonking: libanyevent-ftp-perl 0.20-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms