The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

EntityModel::Gather - asynchronous helper functions for EntityModel

VERSION

version 0.015

SYNOPSIS

 use EntityModel::Gather;

DESCRIPTION

Wrapper class for executing code once data values have been populated.

Given a set of data key => value pairs, this module will request population from each provider. Once all data values are available, the on_ready event is triggered, and the data values are passed to the provided handler. If it is impossible to retrieve data values for some reason, the on_error handler is called instead.

Each of the values passed must be one of the following:

  • Subclass of EntityModel::Pending - requests callback when data value has been populated

  • Subclass of EntityModel::EntityBase - requests callback when populated

  • Scalar value - this will be used as-is

  • undef - this will be used as-is

Any other value will cause the scalar handling to be used.

METHODS

new

Create a new instance. Takes a list of key, value pairs indicating which data values to wait for.

add_pending

Adds the given key and value to the pending list. If the value is immediately available (simple scalar, for example) then this will pass the value through immediately.

AUTHOR

Tom Molesworth <cpan@entitymodel.com>

LICENSE

Copyright Tom Molesworth 2008-2011. Licensed under the same terms as Perl itself.