The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

GX::Callback - Callback class

SYNOPSIS

    # Load the class
    use GX::Callback;
    
    # Create a new callback object
    $callback = GX::Callback->new( sub { say @_ } );
    
    # Execute the callback
    $callback->call( "Hello world!" );

DESCRIPTION

This module provides the GX::Callback class which extends the GX::Class::Object class.

METHODS

Constructor

new

Returns a new GX::Callback object.

    $callback = GX::Callback->new( %attributes );
Attributes:
  • arguments ( ARRAY reference )

    A reference to an array with arguments to pass to the callback subroutine when it is called.

  • code ( CODE reference ) [ required ]

    A reference to the callback subroutine.

Returns:
Exceptions:

Alternative syntax:

    $callback = GX::Callback->new( $code );
Arguments:
  • $code ( CODE reference )

    A reference to the callback subroutine.

Returns:
Exceptions:

Public Methods

arguments

Returns the callback subroutine arguments.

    @arguments = $callback->arguments;
Returns:
  • @arguments ( scalars )

call

Calls the callback subroutine.

    $callback->call( @arguments );
Arguments:
  • @arguments ( scalars )

    Additional arguments to pass to the callback subroutine.

code

Returns a reference to the callback subroutine.

    $code = $callback->code;
Returns:
  • $code ( CODE reference )

SUBCLASSES

The following classes inherit directly from GX::Callback:

SEE ALSO

AUTHOR

Jörg A. Uzarek <uzarek@runlevelnull.de>

COPYRIGHT AND LICENSE

Copyright (c) 2009-2011 Jörg A. Uzarek.

This module is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License Version 3 as published by the Free Software Foundation.