NAME

POE::Component::Sequence::Nested - Adds special features to nested sequences

SYNOPSIS

use POE qw(Component::Sequence::Nested);

POE::Component::Sequence
    ->new(
        {
            auto_pause => 1,
            auto_resume => 1,
            merge_heap => 1,
        },
        sub {
            POE::Component::Sequence
                ->new(
                    sub {
                        my $subseq = shift;
                        $subseq->heap_set(
                            a => 5,
                            b => 19,
                            op => '+',
                        );
                    },
                )->run;
        },
        sub {
            my $sequence = shift;
            my $math = join ' ', map { $sequence->heap_index($_) } qw(a op b);
            $sequence->heap_set(result => eval $math);
        }
    )
    ->add_callback(sub {
        my ($sequence, $result) = @_;
        print "Answer was " . $sequence->heap_index('result') . "\n";
    })
    ->run();

DESCRIPTION

A nested sequence is one in which the return value of an action is another Sequence. When this is the case, we can perform some automated tasks which save each action from redundant calls.

By itself it does nothing, but given any of the following actions, it will do it's magic:

auto_resume

    The parent sequence remains paused, but the child sequence has a callback added onto it which will resume the parent sequence:

    $child_sequence->add_callback(sub {
      $parent_sequence->resume;
    });

auto_error

    This propogates a child sequence failure to the parent via $child->add_error_callback(). This would happen anyway if the child sequence throws an exception, but if the child sequence is already catching errors via another callback

merge_heap

    The heap of the child sequence will be merged with the parent when it's complete:

    $child_sequence->add_finally_callback(sub {
      $parent_sequence->heap_set( $child_sequence->heap );
    });

    This allows for shared heap access.

KNOWN BUGS

No known bugs, but I'm sure you can find some.

SEE ALSO

POE::Component::Sequence

COPYRIGHT

Copyright (c) 2008 Eric Waters and XMission LLC (http://www.xmission.com/). All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the LICENSE file included with this module.

AUTHOR

Eric Waters <ewaters@gmail.com>