NAME

Tk::AppWindow::BaseClasses::Callback - providing callbacks

SYNOPSIS

my $cb = Tk::AppWindow::BaseClasses::Callback->new('MethodName', $owner, @options);
my $cb = Tk::AppWindow::BaseClasses::Callback->new(sub { do whatever }, @options);
$cb->execute(@moreoptions);
$cb->hookBefore('some_method', $obj, @param);
$cb->hookBefore(\&some_sub, @param);
$cb->unhookBefore('some_method', $obj, @param);
$cb->unhookBefore(\&some_sub, @param);
$cb->hookAfter('some_method', $obj, @param);
$cb->hookAfter(\&some_sub, @param);
$cb->unhooAfter('some_method', $obj, @param);
$cb->unhookAfter(\&some_sub, @param);

DESCRIPTION

This module provides means to create universal callbacks.

After creation it can hook and unhook other callbacks to it. Those hooked through the hookBefore method will be called before the main callback. Those hooked through the hookAfter method will be called after the main callback. Results are passed forward through the chain.

METHODS

new

There are two ways to create a new callback;

my $c = Tk::AppWindow::BaseClasses::Callback->new('MethodName', $owner, @options);

When you call execute the options you pass to it will be placed after $owner and before @options

my $c = Tk::AppWindow::BaseClasses::Callback->new(\&SomeAnonymusSub, @options);

When you call execute the options you pass to it will be placed after @options

execute(@options)

Runs the callback and returns the result.

hookAfter(@callback)

Adds a hook to the after section. The items in @callback are exactly as creating a new instance. The callback will be called after the main callback is fed what the main callback returns as parameters.

hookBefore(@callback)

Adds a hook to the before section. The items in @callback are exactly as creating a new instance. The callback will be called before the main callback and feeds it what it returns as parameters.

unhookAfter(@callback)

Removes a hook from the after section. The items in @callback are exactly as when adding the hook. If multiple identical items are present it removes them alls.

unhookBefore(@callback)

Removes a hook from the before section. The items in @callback are exactly as when adding the hook. If multiple identical items are present it removes them all.

AUTHOR

Hans Jeuken (hanje at cpan dot org)

BUGS

Unknown. If you find any, please contact the author.