App::Environ - Simple environment to build applications using service locator pattern
use App::Environ; # Register handlers in your class App::Environ->register( __PACKAGE__, initialize => sub { my $cb = pop if ref( $_[-1] ) eq 'CODE'; my @args = @_; # handling... }, reload => sub { ... }, 'finalize:r' => sub { ... }, ); # Send events from your application # Synchronous interface App::Environ->send_event( 'initialize', qw( foo bar ) ); App::Environ->send_event('reload'); App::Environ->send_event('finalize:r'); # Asynchronous interface App::Environ->send_event( 'initialize', qw( foo bar ), sub { ... } ); App::Environ->send_event( 'reload', sub { ... } ); App::Environ->send_event( 'finalize:r', sub { ... } );
App::Environ is the simple environment to build applications using service locator pattern. Allows register different application components that provide common resources.
Registers handlers for specified events. When an event have been sent, event handlers will be processed in order in which they was registered. If you want that event handlers have been processed in reverse order, add postfix :r to event name.
:r
Sends specified event. All handlers registered for this event will be processed.
App::Environ::Config
Also see examples from the package to better understand the concept.
Eugene Ponizovsky, <ponizovsky@gmail.com>
Copyright (c) 2016, Eugene Ponizovsky, <ponizovsky@gmail.com>. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install App::Environ, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::Environ
CPAN shell
perl -MCPAN -e shell install App::Environ
For more information on module installation, please visit the detailed CPAN module installation guide.