Result:
found more than 837 distributions - search limited to the first 2001 files matching your query ( run in 1.468 )


Callback-Frame

 view release on metacpan or  search on metacpan

lib/Callback/Frame.pm  view on Meta::CPAN


=encoding utf-8

=head1 NAME

Callback::Frame - Preserve error handlers and "local" variables across callbacks

=head1 SYNOPSIS

    use Callback::Frame;

lib/Callback/Frame.pm  view on Meta::CPAN

    synopsis.pl:13 - ANONYMOUS FRAME


=head1 BACKGROUND

When programming with callbacks in perl, you create anonymous functions with C<sub { ... }>. These functions are especially useful because when they are called they will preserve their surrounding lexical environment.

In other words, the following bit of code

    my $callback;
    {

lib/Callback/Frame.pm  view on Meta::CPAN


In order for the callback to have its dynamic environment maintained, you just need to change it to this:

    $watcher = AE::io $sock, 0, fub { do_stuff() };

B<IMPORTANT NOTE>: All callbacks that may be invoked outside the dynamic environment of the current frame should be created with C<frame> or C<fub> so that the dynamic environment will be correctly re-applied when the callback is invoked.

The C<frame_try> and C<frame_catch> subs are equivalent to a call to C<frame> with C<code> and C<catch> parameters. However, unlike with C<frame>, the frame is executed immediately.

C<frame_void> takes a single callback argument. This can be useful if you wish to kick off an unassociated asynchronous action while handling. If the action is run in void context, there is no way for it to throw an exception that will affect your re...

Libraries that wrap callbacks in frames can use the C<Callback::Frame::is_frame()> function to determine if a given callback is already wrapped in a frame. It returns true if the callback is wrapped in a frame and is therefore suitable for use with C...

    if (!Callback::Frame::is_frame($callback)) {
      $callback = frame(code => $callback);
    }

 view all matches for this distribution


Carrot

 view release on metacpan or  search on metacpan

lib/Carrot/Continuity/Coordination/Episode/Target/FD_Nonstop_IO.pm  view on Meta::CPAN

#	file_handle
# //returns
{
	my ($this, $that, $name, $file_handle) = @ARGUMENTS;

	my $callbacks = [];
	foreach my $default_name (@$default_names)
	{
		my $callback = $this->create_callback(
			$that, $default_name, $name);
		push($callbacks, $callback);
	}

#FIXME: this is an assertion
	my $type = Scalar::Util::blessed($file_handle);
	unless ($type eq 'IO::Socket::INET')

lib/Carrot/Continuity/Coordination/Episode/Target/FD_Nonstop_IO.pm  view on Meta::CPAN

		$unsupported_file_class->raise_exception(
			{+HKY_DEX_BACKTRACK => $file_handle,
			 'class' => $type},
			ERROR_CATEGORY_SETUP);
	}
	@$this = ($that, $callbacks, $file_handle, IS_FALSE, fileno($file_handle));
	return;
}

sub hit
# /type method
# /effect ""
# //parameters
#	rwe
# //returns
#	?
{ # one out of four callbacks
	return($_[THIS][ATR_CALLBACK][$_[SPX_RWE]]->($_[THIS][ATR_THAT], @ARGUMENTS));
}

sub validate_fh
# /type method

 view all matches for this distribution


Cassandra-Client

 view release on metacpan or  search on metacpan

lib/Cassandra/Client.pm  view on Meta::CPAN

sub new {
    my ($class, %args)= @_;

    my $self= bless {
        connected         => 0,
        connect_callbacks => undef,
        shutdown          => 0,

        active_queries    => 0,
    }, $class;

lib/Cassandra/Client.pm  view on Meta::CPAN

    # This is ONLY useful if the user doesn't throw away the C::C object on connect errors.
    if (!$self->{connecting} && (my $error= $self->{throttler}->should_fail())) {
        return _cb($callback, $error);
    }

    push @{$self->{connect_callbacks}||=[]}, $callback;
    if ($self->{connecting}++) {
        return;
    }

    my @contact_points= shuffle @{$self->{options}{contact_points}};

lib/Cassandra/Client.pm  view on Meta::CPAN

    $next_connect= sub {
        my $contact_point= shift @contact_points;
        if (!$contact_point) {
            delete $self->{connecting};
            undef $next_connect;
            _cb($_, "Unable to connect to any Cassandra server. Last error: $last_error") for @{delete $self->{connect_callbacks}};
            return;
        }

        my $connection= Cassandra::Client::Connection->new(
            client => $self,

lib/Cassandra/Client.pm  view on Meta::CPAN

            }

            undef $next_connect;
            $self->{connected}= 1;
            delete $self->{connecting};
            _cb($_) for @{delete $self->{connect_callbacks}};
        });
    };
    $next_connect->();

    return;

lib/Cassandra/Client.pm  view on Meta::CPAN

        [ 1, "test", 86400 ],
        { consistency => "quorum" });

=head2 Promises

C<Cassandra::Client> methods are also available as promises (see perldoc L<AnyEvent::XSPromises>). This integrates well with other libraries that deal with promises or asynchronous callbacks. Note that for promises to work, C<AnyEvent> is required, a...

Promise variants are available by prefixing method names with C<async_>, eg. C<async_connect>, C<async_execute>, etc. The usual result of the method is passed to the promise's success handler, or to the failure handler if there was an error.

    # Asynchronously pages through the result set, processing data as it comes in.
    my $promise= $client->async_each_page("SELECT id, column FROM my_table WHERE id=?", [ 5 ], undef, sub {

 view all matches for this distribution


Catalyst-Action-REST

 view release on metacpan or  search on metacpan

lib/Catalyst/Action/Deserialize/Callback.pm  view on Meta::CPAN


extends 'Catalyst::Action';

sub execute {
    my $self = shift;
    my ( $controller, $c, $callbacks ) = @_;

    my $rbody;

    # could be a string or a FH
    if ( my $body = $c->request->body ) {

lib/Catalyst/Action/Deserialize/Callback.pm  view on Meta::CPAN

            $rbody = $body;
        }
    }

    if ( $rbody ) {
        my $rdata = eval { $callbacks->{deserialize}->( $rbody, $controller, $c ) };
        if ($@) {
            return $@;
        }
        $c->request->data($rdata);
    } else {

 view all matches for this distribution


Catalyst-Engine-XMPP2

 view release on metacpan or  search on metacpan

lib/Catalyst/Engine/XMPP2.pm  view on Meta::CPAN


=over

=item $engine->handle_xmpp_node($app, $resource, $node)

This method is called by the stanza callbacks in the connections.

=back

=head1 SEE ALSO

 view all matches for this distribution


Catalyst-Manual

 view release on metacpan or  search on metacpan

lib/Catalyst/Manual/Components.pod  view on Meta::CPAN


=head2 L<Catalyst::Plugin::MobileAgent>

=head2 L<Catalyst::Plugin::Observe>

Provides the ability to register AOP-like callbacks to specific Engine
events. Subclasses L<Class::Publisher>.

=head2 L<Catalyst::Plugin::OrderedParams>

Adjusts the way that parameters operate, causing them to appear in the same

 view all matches for this distribution


Catalyst-Plugin-InjectionHelpers

 view release on metacpan or  search on metacpan

lib/Catalyst/Plugin/InjectionHelpers.pm  view on Meta::CPAN

based on configuration that is controlled per environment.

=head1 DESCRIPTION

B<NOTE> Starting with C<VERSION> 0.012 there is a breaking change in the number
of arguments that the C<method> and C<from_code> callbacks get.  If you need to
keep backwards compatibility you should set the version flag to 1:

    MyApp->config(
      'Plugin::InjectionHelpers' => { version => 1 },
      ## Additional configuration as needed

 view all matches for this distribution


Catalyst-Plugin-Log-Dispatch

 view release on metacpan or  search on metacpan

lib/Catalyst/Plugin/Log/Dispatch.pm  view on Meta::CPAN

            $logc{'class'}  = 'Handle';
            $logc{'handle'} = $io;
        }
        my $class = sprintf( "Log::Dispatch::%s", $logc{'class'} );
        delete $logc{'class'};
        $logc{'callbacks'} = [$logc{'callbacks'}] if(ref($logc{'callbacks'}) eq 'CODE');
        
        if(exists $logc{'format'} and defined $Log::Dispatch::Config::CallerDepth ) {
            my $callbacks = Log::Dispatch::Config->format_to_cb($logc{'format'},0);
            if(defined $callbacks) {
                $logc{'callbacks'} = [] unless($logc{'callbacks'});
                push(@{$logc{'callbacks'}}, $callbacks);
            }
        }
        if( exists $logc{'format_o'} and length( $logc{'format_o'} ) ) {
            my $callbacks = Catalyst::Plugin::Log::Dispatch->_format_to_cb_o($logc{'format_o'},0);
            if(defined $callbacks) {
                $logc{'callbacks'} = [] unless($logc{'callbacks'});
                push(@{$logc{'callbacks'}}, $callbacks);
            }
        }
        elsif(!$logc{'callbacks'}) {
            $logc{'callbacks'} = sub { my %p = @_; return "$p{message}\n"; };
        }
        $class->use or die "$@";
        my $logb = $class->new(%logc);
        $logb->{rtf} = $logc{real_time_flush} || 0;
        $c->log->add( $logb );

lib/Catalyst/Plugin/Log/Dispatch.pm  view on Meta::CPAN

                    $h{name} = $_;
                    if( $self->{outputs}->{$_}->{rtf} ) {
                        $self->{outputs}->{$_}->log(%h);
                    }
                    else {
                        $h{message} = $self->{outputs}->{$_}->_apply_callbacks(%h)
                            if($self->{outputs}->{$_}->{callbacks});
                        push(@{$self->_body}, \%h);
                    }
                }
            }
            else {

lib/Catalyst/Plugin/Log/Dispatch.pm  view on Meta::CPAN

    if ( $self->abort || !(scalar @{$self->_body})) {
        $self->abort(undef);
    }
    else {
        foreach my $p (@{$self->_body}) {
            local $self->{outputs}->{$p->{name}}->{callbacks} = undef;
            $self->{outputs}->{$p->{name}}->log(%{$p});
        }
    }
    $self->_body([]);
}

 view all matches for this distribution


Catalyst-Plugin-Observe

 view release on metacpan or  search on metacpan

lib/Catalyst/Plugin/Observe.pm  view on Meta::CPAN

=head1 DESCRIPTION

Observe Engine events, for debugging purposes. Subclasses
L<Class::Publisher>.

C<Catalyst::Plugin::Observe> allows you to register your own callbacks
to specific Engine events (method calls), and to be notified through the
callback when they occur. When the Engine calls the event, your callback
will be called with the same arguments, which you can then display (etc.)
as necessary.

 view all matches for this distribution


Catalyst-Plugin-RunAfterRequest

 view release on metacpan or  search on metacpan

lib/Catalyst/Plugin/RunAfterRequest.pm  view on Meta::CPAN

use Moose::Role;
use MooseX::Types::Moose qw/ArrayRef CodeRef/;

use namespace::autoclean;

has callbacks => (
    traits  => ['Array'],
    isa     => ArrayRef[CodeRef],
    default => sub { [] },
    handles => {
        run_after_request => 'push',
        _callbacks        => 'elements',
    },
);

after finalize => sub {
    my $self = shift;

    for my $callback ($self->_callbacks) {
        $self->$callback;
    }
};


 view all matches for this distribution


Catalyst-Runtime

 view release on metacpan or  search on metacpan

lib/Catalyst.pm  view on Meta::CPAN

        return $class->registered_data_handlers;
    }
}

sub setup_data_handlers {
    my ($class, %data_handler_callbacks) = @_;
    %data_handler_callbacks = (
      %{$class->default_data_handlers},
      %{$class->config->{'data_handlers'}||+{}},
      %data_handler_callbacks);

    $class->_data_handlers(\%data_handler_callbacks);
}

sub default_data_handlers {
    my ($class) = @_;
    return +{

 view all matches for this distribution


Catalyst-TraitFor-Request-ContentNegotiationHelpers

 view release on metacpan or  search on metacpan

lib/Catalyst/ActionRole/ProvidesMedia.pm  view on Meta::CPAN


  Scalar::Util::weaken($ctx);
  my %media_actions = %{$self->media_actions};
  unless(exists $media_actions{no_match}) {
    $media_actions{no_match} = sub {
      my ($req, %callbacks) = @_;
      $ctx->res->status(406);
      $ctx->res->content_type('text/plain');
      my $allowed = join(',',(keys %callbacks)); 
      $ctx->res->body("You requested a media type we don't support.  Acceptable types are: $allowed");
    };
  }

  my @forwards = map {

 view all matches for this distribution


Catalyst-TraitFor-Request-QueryFromJSONY

 view release on metacpan or  search on metacpan

lib/Catalyst/TraitFor/Request/QueryFromJSONY.pm  view on Meta::CPAN

using L<JSONY>  and return the data references (could be a hashref, or arrayref 
depending on the query construction.

If no @query_params are submitted, assume 'q' as the default.

The %options hash allows you to set callback to handle exceptional conditions. All callbacks
get invoked with two parameters, the current $request object, and the name of the
query parameter that caused the condition.  For example the follow substitutes the string
'[]' when a $key is missing from %{$c->req->query_parameters}:

    $c->req->query_data(qw/a b c/, +{ 

 view all matches for this distribution


Catalyst-View-Component-jQuery

 view release on metacpan or  search on metacpan

Debian_CPANTS.txt  view on Meta::CPAN

"libmarc-crosswalk-dublincore-perl", "MARC-Crosswalk-DublinCore", "0.02", "0", "0"
"libmarc-lint-perl", "MARC-Lint", "1.43", "0", "0"
"libmarc-perl", "MARC", "1.07", "0", "0"
"libmarc-record-perl", "MARC-Record", "2.0.0", "0", "0"
"libmarc-xml-perl", "MARC-XML", "0.88", "0", "0"
"libmasonx-interp-withcallbacks-perl", "MasonX-Interp-WithCallbacks", "1.18", "0", "0"
"libmath-algebra-symbols-perl", "Math-Algebra-Symbols", "1.21", "0", "0"
"libmath-basecalc-perl", "Math-BaseCalc", "1.013", "0", "0"
"libmath-basecnv-perl", "Math-BaseCnv", "1.4.75O6Pbr", "0", "0"
"libmath-bigint-gmp-perl", "Math-BigInt-GMP", "1.24", "1", "0"
"libmath-calc-units-perl", "Math-Calc-Units", "1.06", "0", "0"

 view all matches for this distribution


Catalyst-View-JSON

 view release on metacpan or  search on metacpan

lib/Catalyst/View/JSON.pm  view on Meta::CPAN


=over 4

=item allow_callback

Flag to allow callbacks by adding C<callback=function>. Defaults to 0
(doesn't allow callbacks). See L</CALLBACKS> for details.

=item callback_param

Name of URI parameter to specify JSON callback function name. Defaults
to C<callback>. Only effective when C<allow_callback> is turned on.

lib/Catalyst/View/JSON.pm  view on Meta::CPAN

L<Encode::JavaScript::UCS> to use the encoding.

=head1 CALLBACKS

By default it returns raw JSON data so your JavaScript app can deal
with using XMLHttpRequest calls. Adding callbacks (JSONP) to the API
gives more flexibility to the end users of the API: overcome the
cross-domain restrictions of XMLHttpRequest. It can be done by
appending I<script> node with dynamic DOM manipulation, and associate
callback handler to the returned data.

lib/Catalyst/View/JSON.pm  view on Meta::CPAN


Catalyst::View::JSON makes the data available as a (sort of)
JavaScript to the client, so you might want to be careful about the
security of your data.

=head2 Use callbacks only for public data

When you enable callbacks (JSONP) by setting C<allow_callback>, all
your JSON data will be available cross-site. This means embedding
private data of logged-in user to JSON is considered bad.

  # MyApp.yaml
  View::JSON:

lib/Catalyst/View/JSON.pm  view on Meta::CPAN

      my($self, $c) = @_;
      $c->stash->{address} = $c->user->street_address; # BAD
      $c->forward('View::JSON');
  }

If you want to enable callbacks in a controller (for public API) and
disable in another, you need to create two different View classes,
like MyApp::View::JSON and MyApp::View::JSONP, because
C<allow_callback> is a static configuration of the View::JSON class.

See L<http://ajaxian.com/archives/gmail-csrf-security-flaw> for more.

=head2 Avoid valid cross-site JSON requests

Even if you disable the callbacks, the nature of JavaScript still has
a possibility to access private JSON data cross-site, by overriding
Array constructor C<[]>.

  # MyApp.yaml
  View::JSON:

 view all matches for this distribution


Catalyst-View-Template-PHP

 view release on metacpan or  search on metacpan

lib/Catalyst/View/Template/PHP.pm  view on Meta::CPAN

    }




    # set up PHP module callbacks
    my $OUTPUT = '';
    PHP::options( stdout => sub { $OUTPUT .= $_[0] } );
    PHP::options( stderr => sub { $self->handle_warning($c, $_[0]) } );
    PHP::options( header => sub { $self->header_callback($c, $_[0], $_[1]) } );
    $self->{_headers} = [];

 view all matches for this distribution


Catalyst-View-Template-Pure

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN


0.006   31 August 2016
        - Update version of Template::Pure to close known bugs
        - use weaken in a few places to solve circular references
        - pass the view object to the pure object so that we can use it in
          pure callbacks.
        - Start on new ::Helpers package with first Helper 'Uri' for generating
          correct URIs.

0.005   28 August 2016
        - Update version of Template::Pure to close known bugs

 view all matches for this distribution


CatalystX-CRUD-YUI

 view release on metacpan or  search on metacpan

lib/CatalystX/CRUD/YUI/TT/static/js/crud.js  view on Meta::CPAN


// global var trackers
YAHOO.crud.TABS         = [];
YAHOO.crud.HISTORY      = [];

// set global array of callbacks to execute on form submit
YAHOO.crud.onFormSubmit = [];


/* use FireBug for debugging if it is available */
if (!YAHOO.crud.log) {

 view all matches for this distribution


CatalystX-Example-YUIUploader

 view release on metacpan or  search on metacpan

root/static/js/yui/build/autocomplete/autocomplete-min.js  view on Meta::CPAN

YAHOO.widget.AutoComplete=function(G,B,J,C){if(G&&B&&J){if(J instanceof YAHOO.widget.DataSource){this.dataSource=J;}else{return ;}if(YAHOO.util.Dom.inDocument(G)){if(YAHOO.lang.isString(G)){this._sName="instance"+YAHOO.widget.AutoComplete._nIndex+" "...
YAHOO.util.Event.purgeElement(D,true);D.innerHTML="";for(var C in this){if(YAHOO.lang.hasOwnProperty(this,C)){this[C]=null;}}};YAHOO.widget.AutoComplete.prototype.textboxFocusEvent=null;YAHOO.widget.AutoComplete.prototype.textboxKeyEvent=null;YAHOO.w...
}}if(C[B]==" "){for(var A=C.length-1;A>=0;A--){if(G[E-1]==C[A]){E--;break;}}}if(E>-1){var D=E+1;while(G.charAt(D)==" "){D+=1;}this._sSavedQuery=G.substring(0,D);G=G.substr(D);}else{if(G.indexOf(this._sSavedQuery)<0){this._sSavedQuery=null;}}}if((G&&(...
this._toggleContainer(false);};YAHOO.widget.AutoComplete.prototype._jumpSelection=function(){if(this._oCurItem){this._selectItem(this._oCurItem);}else{this._toggleContainer(false);}};YAHOO.widget.AutoComplete.prototype._moveSelection=function(G){if(t...
YAHOO.widget.DataSource.prototype.dataErrorEvent=null;YAHOO.widget.DataSource.prototype.cacheFlushEvent=null;YAHOO.widget.DataSource._nIndex=0;YAHOO.widget.DataSource.prototype._sName=null;YAHOO.widget.DataSource.prototype._aCache=null;YAHOO.widget.D...
}else{sValue="";}}aFieldSet.unshift(sValue);}aResults.unshift(aFieldSet);}break;case YAHOO.widget.DS_XHR.TYPE_FLAT:if(oResponse.length>0){var newLength=oResponse.length-aSchema[0].length;if(oResponse.substr(newLength)==aSchema[0]){oResponse=oResponse...

 view all matches for this distribution


Catmandu-OAI

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

  - Adding support for default XML::Struct parsing
  - Adding support for passing handlers by name and by invocation
  - Refactoring the RAW XML response into the Catmandu::Importer::OAI::RAW parser

0.04  2014-06-15 20:30:07 CEST
  - switched to the new HTTP::OAI with callbacks
  - adding a network test

0.03  2014-06-15 10:22:55 CEST
  - new option: dry (as supported my Catmandu::Importer::getJSON)
  - new option: listIdentifiers

 view all matches for this distribution


Catmandu-Solr

 view release on metacpan or  search on metacpan

lib/Catmandu/Store/Solr/CQL.pm  view on Meta::CPAN

                            $term = lc $term;
                        }
                    }
                }

                #change term using callbacks
                if (ref $op && $op->{cb}) {
                    my ($pkg, $sub) = @{$op->{cb}};
                    $self->log->debug(
                        "term '$term' changed to ${pkg}->${sub}");
                    $term = require_package($pkg)->$sub($term);

 view all matches for this distribution


Catmandu-Store-MongoDB

 view release on metacpan or  search on metacpan

lib/Catmandu/Store/MongoDB/CQL.pm  view on Meta::CPAN

                        $term = lc $term;
                    }
                }
            }

            #change term using callbacks
            if (ref $op && $op->{cb}) {
                my ($pkg, $sub) = @{$op->{cb}};
                $term = require_package($pkg)->$sub($term);
            }
            elsif ($q_mapping->{cb}) {

 view all matches for this distribution


Centrifugo-Client

 view release on metacpan or  search on metacpan

lib/Centrifugo/Client.pm  view on Meta::CPAN

# This function is called when client is connected to the WebSocket
sub _on_ws_connect {
	my ($this) = @_;
	$this->_debug( "Centrifugo::Client : WebSocket connected to $this->{WS_URL}" );
	
	# define the callbacks
	$this->{WSHANDLE}->on(each_message => sub { $this->_on_ws_message($_[1]) });
	$this->{WSHANDLE}->on(finish => sub { $this->_on_close(($_[0])->close_reason()) });
	$this->{WSHANDLE}->on(parse_error => sub {
		my($cnx, $error) = @_;
		$this->_debug( "Error in Centrifugo::Client : $error" );

 view all matches for this distribution


Changes

 view release on metacpan or  search on metacpan

lib/Changes.pm  view on Meta::CPAN

    }
    $self->elements( $elements );
    return( $self );
}

sub preamble { return( shift->_set_get_scalar_as_object( { field => 'preamble', callbacks => 
{
    set => sub
    {
        my( $self, $text ) = @_;
        if( defined( $text ) && $text->defined )

 view all matches for this distribution


Chart-GGPlot

 view release on metacpan or  search on metacpan

lib/Chart/GGPlot/Setup.pm  view on Meta::CPAN

                min_level => 'debug',
                newline   => 1,
                stderr    => 1,
            ]
        ],
        callbacks => sub {
            my %params = @_;
            my $msg = $params{message};
            my $level = uc($params{level});
            return sprintf("%s [Chart::GGPlot $level] %s", strftime('%Y-%m-%d %H:%M:%S', localtime(time)), $msg);
        },

 view all matches for this distribution


Chart-Plotly

 view release on metacpan or  search on metacpan

share/plotly.js/plotly.min.js  view on Meta::CPAN

 * The buffer module from node.js, for the browser.
 *
 * @author   Feross Aboukhadijeh <https://feross.org>
 * @license  MIT
 */
"use strict";var e=t("base64-js"),n=t("ieee754");r.Buffer=a,r.SlowBuffer=function(t){+t!=t&&(t=0);return a.alloc(+t)},r.INSPECT_MAX_BYTES=50;function i(t){if(t>2147483647)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=ne...
/*! Native Promise Only
    v0.8.1 (c) Kyle Simpson
    MIT License: http://getify.mit-license.org
*/
!function(t,r,n){r[t]=r[t]||n(),void 0!==e&&e.exports&&(e.exports=r[t])}("Promise",void 0!==t?t:this,(function(){"use strict";var t,e,n,i=Object.prototype.toString,a=void 0!==r?function(t){return r(t)}:setTimeout;try{Object.defineProperty({},"x",{}),...

 view all matches for this distribution


Chess-GameClock-GameClock

 view release on metacpan or  search on metacpan

lib/Chess/GameClock/GclkCounter.pm  view on Meta::CPAN


    $whites=GclkCounter->new ;
    $whites->init($arg,$color) ;
    $whites-> cntupdate{$timestamp);
    $whites->print ;
#  the functions hereafter are only used  inside callbacks
    &start($whites,$blacks,$mainwindow,$white_move_button,$black_move_button)= ;
    &stop($halt_button,$whites,$blacks) ;
    &capture($mouse_event,$whites,$blacks ) ;

=head1 EXPORT

 view all matches for this distribution


Chouette

 view release on metacpan or  search on metacpan

lib/Chouette.pm  view on Meta::CPAN


=item L<Callback::Frame>

Makes exception handling simple and convenient. You can C<die> anywhere and it will only affect the request being currently handled.

Important note: If you are using 3rd-party libraries that accept callbacks, please understand how L<Callback::Frame> works. You will usually need to pass C<fub {}> instead of C<sub {}> to these libraries. See the L<EXCEPTIONS> section for more detail...

=item L<Session::Token>

For random identifiers such as session tokens (obviously).

lib/Chouette.pm  view on Meta::CPAN


If you want a config file, this path is where it will be read from. The file's format is L<YAML>. The values in this file over-ride the values in C<config_defaults>. If this parameter is not provided then it will not attempt to load a config file and...

=item C<routes>

Routes are specified as a hash-ref of route paths, mapping to hash-refs of methods, mapping to package+function names or callbacks. For example:

    routes => {
        '/myapi/resource' => {
            POST => 'MyAPI::Resource::create',
            GET => 'MyAPI::Resource::get_all',

lib/Chouette.pm  view on Meta::CPAN


    $c->done;

You will need to send a response later, usually from an async callback. Note: If the last reference to the context is destroyed without a response being sent, the message C<no response was sent, sending 500> will be logged and a 500 "internal server ...

You don't ever need to call C<done>. You can just C<return> from the handler instead. C<done> is only for convenience in case you are deeply nested in callbacks and don't want to worry about writing a bunch of nested returns.

=item C<respond_raw>

Similar to C<respond> except it doesn't assume JSON encoding:

lib/Chouette.pm  view on Meta::CPAN

        } else {
            # failure. error message is in $@
        }
    });

Even if C<exec> failed, the callback still gets called. Whether or not it succeeded is indicated by its parameters. You can think of this as a sort of "in-band" signalling. The fact that there was an error, and what exactly that error was, needs to b...

But with both of these methods, what should the callback do when it is notified of an error? It can't just C<die> because nothing will catch the exception. With the L<EV> event loop you will see this:

    EV: error in callback (ignoring): failure: ERROR:  relation "no_such_table" does not exist

lib/Chouette.pm  view on Meta::CPAN


Perhaps most importantly, if some unexpected exception is thrown by your callback (or something that it calls) then the event loop will receive an exception and nothing will get logged or replied to.

=back

For these reasons, Chouette uses L<Callback::Frame> to deal with exceptions. The idea is that the exception handling code is carried around with your callbacks. For instance, this is how you would accomplish the same thing with Chouette:

    my $dbh = $c->task('db');

    $dbh->selectrow_arrayref("SELECT * FROM no_such_table", undef, sub {
        my ($dbh, $rows) = @_;

lib/Chouette.pm  view on Meta::CPAN

        # Even if I can die here and it will get routed to the right request!
    });

The callback will only be invoked in the success case. If a failure occurs, an exception will be raised in the dynamic scope that was in effect when the callback was installed. Because Chouette installs a C<catch> handler for each request, an appropr...

Important note: Libraries like L<AnyEvent::Task> (which is what C<task> in the above example uses) are L<Callback::Frame>-aware. This means that you can pass C<sub {}> callbacks into them and they will automatically convert them to C<fub {}> callback...

When using 3rd-party libraries, you must pass C<fub {}> instead. Also, you'll need to figure out how the library handles error cases, and throw exceptions as appropriate. For example, if you really wanted to use L<AnyEvent::DBI> (even though the L<An...

    $dbh->exec("SELECT * FROM no_such_table", fub {
        my ($dbh, $rows, $rv) = @_;

lib/Chouette.pm  view on Meta::CPAN

        # success
    });

Note that the C<sub> has been changed to C<fub> and an exception is thrown for the error case.

In summary, when installing callbacks you must use C<fub> except when the library is L<Callback::Frame>-aware.

Please see the L<Callback::Frame> documentation for more specifics.


=head2 CONTROL FLOW

 view all matches for this distribution



Class-Accessor-Inherited-XS

 view release on metacpan or  search on metacpan

lib/Class/Accessor/Inherited/XS.pm  view on Meta::CPAN

    use Class::Accessor::Inherited::XS {
        inherited    => ['foo'],
        inherited_cb => ['bar'],
    };

You can register new inherited accessor types with associated read/write callbacks. Unlike
L<Class::Accessor::Grouped>, only a single callback can be set for a type, without per-class
B<get_$type>/B<set_$type> lookups. You can omit either B<on_read> or B<on_write> if you don't
need it to avoid performance losses from associated call.

B<on_read> callback receives a single argument - return value from the underlying B<inherited> accessor. It's result

 view all matches for this distribution


( run in 1.468 second using v1.01-cache-2.11-cpan-9b1e4054eb1 )