Dancer2...Delayed(3)
π Dancer2::Core::Response::Delayed β Delayed responses π
okay bestie, so this is a page from the User Contributed Perl Documentation, and it's about Dancer2::Core::Response::Delayed. Yes the name is a whole mouthful, we love that for it. It's giving "delayed responses" and honestly? Iconic.
β¨ VERSION β¨
version 2.2.1
π¦ SYNOPSIS π¦
So you can build one directly, like this:
my $response = Dancer2::Core::Response::Delayed->new(
request => Dancer2::Core::Request->new(...),
response => Dancer2::Core::Response->new(...),
cb => sub {...},
# optional error handling
error_cb => sub {
my ($error) = @_;
...
},
);
orrr you can do it inside an app, which is lowkey the more fun way:
# or in an app
get '/' => sub {
# delayed response:
delayed {
# streaming content
content "data";
content "more data";
# close user connection
done;
} on_error => sub {
my ($error) = @_;
warning 'Failed to stream to user: ' . request->remote_address;
};
};
no cap, that on_error block is doing the most and we respect it π«Ά
πΈ DESCRIPTION πΈ
This object is literally a delayed (asynchronous) response for Dancer2. You get at it through the delayed keyword.
The whole vibe here is that it holds onto references to a request and a response β specifically so it does not have to hold onto a reference to the application. Efficient queen behavior π
π ATTRIBUTES π
request
Holds the request that this delayed response is using.
In a web request context, this is gonna be the request that existed at the exact moment the delayed response was created. iykyk.
response
Holds the response that this delayed response is using.
Same deal β in a web request context, this is the response that existed back when the delayed response got created. π°οΈ
cb
The code that gets run asynchronously. That's it, that's the whole thing.
error_cb
A callback for handling errors. It receives the error as its first parameter β and, as of right now, its only parameter. So like, one arg bestie, don't come for me.
β METHODS β
is_halted
A method that tells you whether the response has halted.
ngl, in the context of an asynchronous request this is completely useless, so it just returns no.
Heads up: this method is likely going away. π
has_passed
A method that tells you whether the response asked to skip the current response.
Also useless in the context of an asynchronous request, so it also just returns no. Matching set β¨
Also on the chopping block: this method is likely going away.
to_psgi
Creates a PSGI response. Here's how it goes, step by step, no gatekeeping:
It returns a proper PSGI response subroutine. That subroutine localizes the request and the response β this is so the callback can go edit them without needing an actual reference to them β and then it calls the callback.
Then, finally, when the callback is done doing its thing, it asks the response (whether it got changed or not, doesn't matter) to create its own PSGI response by calling to_psgi, and sends that off to the callback it receives as a delayed response. full circle moment π₯
π AUTHOR π
Dancer Core Developers
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2026 by Alexis Sukrieh.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. periodt.
and that's the whole page babes π©· this was perl v5.42.3, dated 2026-09-20, and yes, it's Dancer2...Delayed(3) β mwah, go stream some responses πβ¨
π¦ where this page comes from
- fedora 44: perl-Dancer2 2.2.1-1.fc44 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms