NAME
Aion::Emitter - event dispatcher
SYNOPSIS
File lib/Event/BallEvent.pm:
package Event::BallEvent;
use Aion;
has radius => (is => 'rw', isa => Num);
has weight => (is => 'rw', isa => Num);
1;
File lib/Listener/RadiusListener.pm:
package Listener::RadiusListener;
use Aion;
#@listen Event::BallEvent
sub listen {
my ($self, $event) = @_;
$event->radius(10);
}
1;
File lib/Listener/WeightListener.pm:
package Listener::WeightListener;
use Aion;
#@listen Event::BallEvent
sub listen {
my ($self, $event) = @_;
$event->weight(12);
}
#@listen Event::BallEvent#mini „Minimize version”
sub minimize {
my ($self, $event) = @_;
$event->weight(3);
}
1;
File etc/annotation/listen.ann:
Listener::RadiusListener#listen,6=Event::BallEvent
Listener::WeightListener#listen,6=Event::BallEvent
Listener::WeightListener#minimize,6=Event::BallEvent#mini „Minimize version”
use lib 'lib';
use Aion::Emitter;
use Event::BallEvent;
my $emitter = Aion::Emitter->new;
my $ballEvent = Event::BallEvent->new;
$emitter->emit($ballEvent);
$ballEvent->radius # -> 10
$ballEvent->weight # -> 12
$ballEvent->radius(0);
$emitter->emit($ballEvent, "mini");
$ballEvent->weight # -> 3
$ballEvent->radius # -> 0
DESCRIPTION
This event dispatcher implements the Event Dispatcher pattern in which an event is defined by the class of the event object (event).
The listener is registered as an aeon in the pleroma and will always be represented by one object.
The event processing method is marked with the #@listen annotation.
SUBROUTINES
emit ($event, [$key])
Emits an event: calls all listeners associated with the $event event.
The additional parameter $key allows you to specify a qualifying event. Imagine that we have many controllers and we want to emit an event not for all, but for each specific controller. Writing a class that extends the request class for each controller is wasteful.
$key can contain letters, numbers, underscores, dashes, colons and periods.
AUTHOR
Yaroslav O. Kosmina mailto:dart@cpan.org
LICENSE
⚖ Perl5
COPYRIGHT
The Aion::Emitter module is copyright (c) 2026 Yaroslav O. Kosmina. Rusland. All rights reserved.