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

NAME

Jifty::Continuation - Allows for basic continuation-based programming

DESCRIPTION

Jifty::Continuation wraps up the information about a context that might have been expecting some sort of answer. It allows one to re-visit that context later by providing the continuation again. Continuations are stored on the user's session.

Continuations store a Jifty::Request object and the Jifty::Response object for the request. They can also store arbitrary code to be run when the continuation is called.

Continuations can also be arbitrarily nested. This means that returning from one continuation will drop you into the continuation that is one higher in the stack.

Continuations are generally created just before their request would take effect, activated by the presence of certain query parameters. The rest of the request is saved, its execution to be continued at a later time.

Continuations are run after any actions have run. When a continuation is run, it restores the request that it has saved away into it, and pulls into that request the values any return values that were specified when it was created. The continuations code block, if any, is then called, and then the filled-in request is then run "handle_request" in Jifty::Web.

new PARAMHASH

Saves a continuation at the current state. Possible arguments in the PARAMHASH:

parent

A Jifty::Continuation object, or the id of one. This represents the continuation that this continuation should return to when it is called. Defaults to the current continuation of the current Jifty::Request.

request

The Jifty::Request object to save away. Defaults to an empty Jifty::Request object.

response

The Jifty::Response object that will be loaded up when the continuation is run. Most of the time, the response isn't stored in the continuation, since the continuation was saved away before the actions got run. In the case when continuations are used to preserve state across a redirect, however, we tuck the Jifty::Response value of the previous request into the continuation as well. Defaults to an empty Jifty::Response object.

code

An optional subroutine reference to evaluate when the continuation is called.

clone

There is a interface to support continuation "cloning," a process which is useful to creating multi-page wizards and the like. However, this feature is still very much in flux; the documentation is waiting for the interface to settle down a bit before being written.

call

Call the continuation; this is generally done during request processing, after an actions have been run. Jifty::Request::Mapper-controlled values are filled into the stored request based on the current request and response. If an values needed to be filled in, then *another* continuation is created, with the filled-in values included, and the browser is redirected there. This is to ensure that we end up at the correct request path, while keeping continuations immutable and maintaining all of the request state that we need.

delete

Remove the continuation, and any continuations that would return to its scope, from the session.