[Catalyst] Continuations anyone? :)
Sebastian Riedel
sri at oook.de
Sat Apr 22 07:49:56 CEST 2006
22.04.2006 00:06 Yuval Kogman:
> BLAM! BANG! BOOM!
>
> Our pseudo-continuations have changed. Radically.
Radically! :)
package MyApp::Controller::Test;
use base 'Catalyst::Controller';
sub counter : Global {
my ( $self, $c ) = @_;
my $up = $c->continue('up');
my $down = $c->continue('down');
my $counter = $c->stash>{counter} || 0;
$c->res->body(<<"EOF");
Counter: $counter<br/>
<a href="$up">++</a>
<a href="$down">--</a>
EOF
}
sub up : Private { $_[1]->stash->{counter}++ }
sub down : Private { $_[1]->stash->{counter}-- }
It works much like forward() now, no more action classes needed here.
$up and $down are now objects that can do very cool things and
stringify to the continuation url.
--
sebastian
More information about the Catalyst
mailing list