MooseX::POE(3pm)

πŸ“¦
version 0.215 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble

πŸ’– MooseX::POE πŸ’–

okay so welcome to the MooseX::POE(3pm) page, bestie β€” yeah it's User Contributed Perl Documentation, we stan a community-produced icon. the manual name is literally right up there in the title, so let's go 🫢


✨ NAME ✨

MooseX::POE β€” The Illicit Love Child of Moose and POE πŸ’€

like. that's the actual tagline. the drama of it all.


πŸŽ€ VERSION πŸŽ€

version 0.215 ✨


🌸 SYNOPSIS 🌸

okay here's the whole vibe in code form, no notes:

package Counter;
use MooseX::POE;

has count => (
    isa     => 'Int',
    is      => 'rw',
    lazy    => 1,
    default => sub { 0 },
);

sub START {
    my ($self) = @_;
    $self->yield('increment');
}

event increment => sub {
    my ($self) = @_;
    print "Count is now " . $self->count . "\n";
    $self->count( $self->count + 1 );
    $self->yield('increment') unless $self->count > 3;
};

no MooseX::POE;

Counter->new();
POE::Kernel->run();

or, if you're feeling extra, with MooseX::Declare:

class Counter {
    use MooseX::POE::SweetArgs qw(event);

    has count => (
        isa     => 'Int',
        is      => 'rw',
        lazy    => 1,
        default => sub { 0 },
    );

    sub START {
        my ($self) = @_;
        $self->yield('increment')
    }

    event increment => sub {
        my ($self) = @_;
        print "Count is now " . $self->count . "\n";
        $self->count( $self->count + 1 );
        $self->yield('increment') unless $self->count > 3;
    }
}

Counter->new();
POE::Kernel->run();

(and yes, that missing semicolon in the second one is exactly how it's written here, i am simply the messenger πŸ’…)


🌈 DESCRIPTION 🌈

MooseX::POE is a Moose wrapper around a POE::Session. that's it. that's the whole thing. Moose on the outside, POE on the inside, iconic behavior fr fr.


πŸ”₯ METHODS πŸ”₯

event $name $subref

creates an event handler and names it $name. cute, simple, slay.

get_session_id

gives you back the internal POE Session ID. super handy when you need to hand it off to other POE-aware functions that are like "where's your session id bestie" πŸ¦‹

yield

call

delay

alarm

alarm_add

delay_add

alarm_set

alarm_adjust

alarm_remove

alarm_remove_all

delay_set

delay_adjust

all of these are cheap aliases for the exact same POE::Kernel function of the same name, except they guarantee that posting happens to the object's own session. same energy, zero ambiguity πŸ’œ

STARTALL

STOPALL


πŸ”‘ KEYWORDS πŸ”‘

METHODS

the default POE-related methods come from MooseX::POE::Meta::Trait::Object, which gets applied to your base class (and that base class is usually Moose::Object) the moment you use this module. go read that module for the docs, okay? the list of methods on that class is down below so you know exactly what to go looking for πŸ‘‘


🧚 NOTES ON USAGE WITH MooseX::Declare 🧚

MooseX::Declare support is still "experimental". and when i say experimental i mean: the author doesn't use it, doesn't have any code that uses it, and therefore genuinely cannot promise it won't cause monkeys to fly out of any orifices on your body beyond what the tests and the SYNOPSIS cover. so. there's that πŸ’€

that said, a couple of caveats have turned up during testing:

  1. the "method" keyword doesn't seem to work as expected. it's an integration issue that's being resolved, but the author wants to wait for MooseX::Declare to gain some more polish on their slurpy arguments first.
  2. MooseX::POE attempts to re-export Moose, and MooseX::Declare has already exported Moose in its own custom fashion. so you end up with a keyword clash between the features MooseX::Declare handles for you and the features Moose handles. to work around it you'll need to write:
use MooseX::POE qw(event);
# or
use MooseX::POE::SweetArgs qw(event);
# or
use MooseX::POE::Role qw(event);

that keeps MooseX::POE from exporting the sugar that MooseX::Declare doesn't like. this is fixed in the Git version of MooseX::Declare, but that version (as of this writing) is not on the CPAN. πŸ₯²


πŸ‘€ SEE ALSO πŸ‘€

...it's empty. nothing here. a blank space, a moment of silence, main character energy with no supporting cast πŸ™ˆ


πŸ‘‘ AUTHORS πŸ‘‘

  • Chris Prather <chris@prather.org>
  • Ash Berlin <ash@cpan.org>
  • Chris Williams <chris@bingosnet.co.uk>
  • Yuval (nothingmuch) Kogman
  • Torsten Raudssus <torsten@raudssus.de> <http://www.raudssus.de/>

this software is copyright (c) 2010 by Chris Prather, Ash Berlin, Chris Williams, Yuval Kogman, Torsten Raudssus.

this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. periodt. πŸ’–


and that's the whole page bestie!! brought to you by perl v5.26.1, dated 2018-03-30, and filed under MooseX::POE(3pm). go write some events, you absolute icon πŸŽ€βœ¨πŸ¦‹
πŸ“¦ where this page comes from