Data::Stream::Bulk::Callback - Callback based bulk iterator


Data-Stream-Bulk documentation Contained in the Data-Stream-Bulk distribution.

Index


Code Index:

NAME

Top

Data::Stream::Bulk::Callback - Callback based bulk iterator

SYNOPSIS

Top

    Data::Stream::Bulk::Callback->new(
        callback => sub {
            if ( @more_items = get_some() ) {
                return \@more_items;
            } else {
                return; # done
            }
        },
    }

DESCRIPTION

Top

This class provides a callback based implementation of Data::Stream::Bulk.

ATTRIBUTES

Top

callback

The subroutine that is called when more items are needed.

Should return an array reference for the next block, or a false value if there is nothing left.

METHODS

Top

get_more

See Data::Stream::Bulk::DoneFlag.

Reinvokes callback.

AUTHOR

Top

Yuval Kogman <nothingmuch@woobling.org>

COPYRIGHT AND LICENSE

Top


Data-Stream-Bulk documentation Contained in the Data-Stream-Bulk distribution.

package Data::Stream::Bulk::Callback;
BEGIN {
  $Data::Stream::Bulk::Callback::AUTHORITY = 'cpan:NUFFIN';
}
BEGIN {
  $Data::Stream::Bulk::Callback::VERSION = '0.08';
}
# ABSTRACT: Callback based bulk iterator

use Moose;

use namespace::clean -except => 'meta';

with qw(Data::Stream::Bulk::DoneFlag) => { -excludes => [qw(is_done finished)] };

has callback => (
    isa => "CodeRef|Str",
    is  => "ro",
    required => 1,
    clearer  => "finished",
);

sub get_more {
    my $self = shift;
    my $cb = $self->callback;
    $self->$cb;
}

__PACKAGE__->meta->make_immutable;

__PACKAGE__;



__END__