NAME

Continuity::RequestCallbacks - Mix callbacks into the Continuity request object

SYNOPSYS

use Continuity;
use Continuity::RequestCallbacks;

Continuity->new->loop;

sub main {
  my $request = shift;
  my $link_yes = $request->callback_link( Yes => sub {
    $request->print("You said yes! (please reload)");
    $request->next;
  });
  my $link_no = $request->callback_link( No => sub {
    $request->print("You said no! (please reload)");
    $request->next;
  });
  $request->print(qq{
    Do you like fishies?<br>
    $link_yes $link_no
  });
  $request->next;
  $request->execute_callbacks;
  $request->print("All done here!");
}

DESCRIPTION

This adds some methods to the $request object so you can easily do some callbacks.

METHODS

$html = $request->callback_link( "text" => sub { ... } );

Returns the HTML for an href callback.

$html = $request->callback_submit( "text" => sub { ... } );

Returns the HTML for a submit button callback.

$request->execute_callbacks

Execute callbacks, based on the params in $request. Call this after you've displayed the form and then done $request->next.

We don't call this from within $request->next in case you need to do some processing before executing callbacks. Checking authentication is a good example of something you might be doing inbetween :)