Adapter-Async

 view release on metacpan or  search on metacpan

lib/Adapter/Async/OrderedList.pm  view on Meta::CPAN

package Adapter::Async::OrderedList;
$Adapter::Async::OrderedList::VERSION = '0.019';
use strict;
use warnings;

use parent qw(Adapter::Async);

=head1 NAME

Adapter::Async::OrderedList - API for dealing with ordered lists

=head1 VERSION

version 0.018

=head1 DESCRIPTION

=head2 Accessing data

=over 4

=item * count - resolves with the number of items. If this isn't possible, an estimate may be acceptable.

 say "items: " . $adapter->count->get

=item * get - accepts a list of indices

 $adapter->get(
  items   => [1,2,3],
  on_item => sub { ... }
 )->on_done(sub { warn "all done, full list of items: @{$_[0]}" })

The returned list of items are guaranteed not to be modified further, if you want to store the arrayref directly.

=back

This means we have double-notify on get: a request for (1,2,3,4) needs to fire events for each of 1,2,3,4, and also return the list of all of them on completion (by resolving a Future).

=head2 Modification

=over 4

=item * clear - remove all data

=item * splice - modify by adding/removing items at a given point

=item * modify - changes a single entry

=back

Helper methods provide the following:

=over 4

=item * insert - splice $idx, @data, 0

=item * append - splice $idx + 1, @data, 0

=back

=head2 Events

All events are shared over a common bus for each data source, in the usual fashion - adapters and views can subscribe to the ones they're interested in, and publish events at any time.

The adapter raises these:



( run in 0.665 second using v1.01-cache-2.11-cpan-39bf76dae61 )