Hello,

This is a working example how it can be achieved. Can it be the right
way while MX::POE is not compatible?

#!/usr/bin/perl -w
use strict;


use MooseX::Declare;
class Foo is mutable extends MooseX::POE::Object {
    BEGIN { Class::MOP::remove_metaclass_by_name(__PACKAGE__); };
    use MooseX::POE qw/event/;
    MooseX::POE->init_meta( for_class => __PACKAGE__ );

    has name => (
        isa     => 'Str',
        is      => 'rw',
        default => sub { 'Foo ' },
    );

    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;
    };
}


use POE;
Foo->new();
POE::Kernel->run();

Reply via email to