Mixin::...h::Event(3)
π¦ Mixin::Event::Dispatch::Event β an event object π¦
So this whole page lives in the Mixin::Event::Dispatch::Event neighborhood of the Perl docs β it's a User Contributed Perl Documentation page, bestie, and it's literally all about one little object: the event itself. π
β¨ VERSION β¨
version 2.000 β that's the vibe check result, we're on 2.000. π
πΈ SYNOPSIS πΈ
Okay so here's the whole thing in action, copying exactly:
my $self = shift;
my $ev = Mixin::Event::Dispatch::Event->new(
name => 'some_event',
instance => $self,
);
$ev->dispatch;
That's it. That's the whole flex. Build the event, then dispatch it. Slay. β
π DESCRIPTION π
This class hands you an object you can use to actually interact with the current event β like, the event that's happening right now, in your handler, in real time. That's the entire job. Iconic, honestly. π«Ά
π§ METHODS π§
π new
Constructor time! It takes these named parameters, and yes, all of them are named:
nameβ the name of this event πinstanceβ the originating instance πparentβ anotherMixin::Event::Dispatch::Eventobject, but only if we got invoked from inside an existing handler πhandlersβ the list of handlers for this event β¨
Ngl, the implementation here is peculiar on purpose β they're assuming that time is of the essence. πββοΈπ¨ Also important: this constructor is rarely called in practice, becauseMixin::Event::Dispatchusesblessdirectly instead. So don't be shocked if you never touch it.
Returns $self. π
π READ-ONLY ACCESSORS π
πΈ name
Returns the name of this event. That's it, that's the method. π¦
π₯ is_deferred
Returns true if this event has been deferred. What that actually means: another handler is active, and it has allowed the remaining handlers to take over the event β and once those other handlers finish up, the original handler gets resumed. So it's like a "brb, someone else is driving" flag. π
π is_stopped
Returns true if this event has been stopped. Meaning: no further handlers will be called. Full stop, no cap. π
β instance
Returns the original object instance that the invoke_event method in Mixin::Event::Dispatch was called on.
Heads up though β this can be different from the instance we're currently handling, in cases like event delegation. So don't assume they're the same, bestie. π
π§ parent
Returns the parent Mixin::Event::Dispatch::Event, if there was one. And usually there wasn't. π
π handlers
Returns a list of the remaining handlers for this event. Anything that's already been called gets removed from this list, so it's a live "who's left" roster. π
π stop
Stops processing for this event. Prevents any further event handlers from being called. The nuclear option, and sometimes you just need it. π₯
π dispatch
Dispatches this event. It takes the parameters that were originally passed to invoke_event in Mixin::Event::Dispatch β with the exception of the event name β and passes them on to the defined handlers. So it's like forwarding the group chat to the handlers. π²
Returns $self. β¨
π play
Continues the current event. Do not use. π¨
The semantics here are subject to change, so seriously, avoid this and consider defer instead. And plot twist: currently it does nothing anyway.
Returns $self. π
π¦ defer
Defers this event. π
Cause: the remaining handlers get called, and the event gets marked as is_deferred.
Here's the example, exactly as given:
sub {
my $ev = shift;
print "Deferring\n";
$ev->defer(@_);
print "Finished deferring\n";
}
Returns $self. β
π«Ά unsubscribe
Unsubscribes the current handler from the event that we're processing at the moment. Perfect for one-shot handlers or limited-lifetime handlers β you know, the "I'm only here for a few calls" kind of energy. βοΈ
The example, verbatim:
my $count = 0;
$obj->subscribeto_event(
som_event => sub {
my $ev = shift;
return $ev->unsubscribe if ++$count > 3;
print "Current count: $count\n";
}
);
$obj->invoke_event('some_event') for 1..5;
Returns $self. π
π debug_print
Shows a debug message. It should only be called if the appropriate (compile-time) flag is set, like this:
$self->debug_print(...) if DEBUG;
and not by expecting this:
$self->debug_print(...);
to do the checking for you. It won't. It's not doing that. You have to guard it yourself. π
Returns $self. πΈ
π AUTHOR π
Tom Molesworth <cpan@perlsite.co.uk> β the main character who wrote all this. π«Ά
π LICENSE π
Copyright Tom Molesworth 2012-2014. Licensed under the same terms as Perl itself.
and that's the whole page, bestie β go forth and dispatch π β¨
Sign-off vibes: this page is from perl v5.42.2, dated 2026-02-15 β remember it when you're citing your sources in the group chat ππ¦
π¦ where this page comes from
- alpine 3.24: perl-mixin-event-dispatch-doc 2.000-r1 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms