Skip to content

Commit

Permalink
more consistent event examples
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Nov 2, 2015
1 parent 45ac0d8 commit 3d149c6
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 16 deletions.
3 changes: 1 addition & 2 deletions lib/Mojo/Content.pm
Expand Up @@ -342,8 +342,7 @@ Emitted once all data has been written.
Emitted when a new chunk of content arrives.
$content->unsubscribe('read');
$content->on(read => sub {
$content->unsubscribe('read')->on(read => sub {
my ($content, $bytes) = @_;
say "Streaming: $bytes";
});
Expand Down
3 changes: 1 addition & 2 deletions lib/Mojo/Log.pm
Expand Up @@ -114,8 +114,7 @@ following new ones.
Emitted when a new message gets logged.
$log->unsubscribe('message');
$log->on(message => sub {
$log->unsubscribe('message')->on(message => sub {
my ($log, $level, @lines) = @_;
say "$level: ", @lines;
});
Expand Down
3 changes: 1 addition & 2 deletions lib/Mojo/Server.pm
Expand Up @@ -115,8 +115,7 @@ following new ones.
Emitted when a request is ready and needs to be handled.
$server->unsubscribe('request');
$server->on(request => sub {
$server->unsubscribe('request')->on(request => sub {
my ($server, $tx) = @_;
$tx->res->code(200);
$tx->res->headers->content_type('text/plain');
Expand Down
3 changes: 1 addition & 2 deletions lib/Mojo/Server/CGI.pm
Expand Up @@ -77,8 +77,7 @@ Mojo::Server::CGI - CGI server
use Mojo::Server::CGI;
my $cgi = Mojo::Server::CGI->new;
$cgi->unsubscribe('request');
$cgi->on(request => sub {
$cgi->unsubscribe('request')->on(request => sub {
my ($cgi, $tx) = @_;
# Request
Expand Down
3 changes: 1 addition & 2 deletions lib/Mojo/Server/Daemon.pm
Expand Up @@ -255,8 +255,7 @@ Mojo::Server::Daemon - Non-blocking I/O HTTP and WebSocket server
use Mojo::Server::Daemon;
my $daemon = Mojo::Server::Daemon->new(listen => ['http://*:8080']);
$daemon->unsubscribe('request');
$daemon->on(request => sub {
$daemon->unsubscribe('request')->on(request => sub {
my ($daemon, $tx) = @_;
# Request
Expand Down
3 changes: 1 addition & 2 deletions lib/Mojo/Server/PSGI.pm
Expand Up @@ -76,8 +76,7 @@ Mojo::Server::PSGI - PSGI server
use Mojo::Server::PSGI;
my $psgi = Mojo::Server::PSGI->new;
$psgi->unsubscribe('request');
$psgi->on(request => sub {
$psgi->unsubscribe('request')->on(request => sub {
my ($psgi, $tx) = @_;
# Request
Expand Down
3 changes: 1 addition & 2 deletions lib/Mojo/Server/Prefork.pm
Expand Up @@ -211,8 +211,7 @@ Mojo::Server::Prefork - Preforking non-blocking I/O HTTP and WebSocket server
use Mojo::Server::Prefork;
my $prefork = Mojo::Server::Prefork->new(listen => ['http://*:8080']);
$prefork->unsubscribe('request');
$prefork->on(request => sub {
$prefork->unsubscribe('request')->on(request => sub {
my ($prefork, $tx) = @_;
# Request
Expand Down
3 changes: 1 addition & 2 deletions lib/Mojo/Transaction/WebSocket.pm
Expand Up @@ -404,8 +404,7 @@ Emitted when the WebSocket connection has been closed.
Emitted when a WebSocket frame has been received.
$ws->unsubscribe('frame');
$ws->on(frame => sub {
$ws->unsubscribe('frame')->on(frame => sub {
my ($ws, $frame) = @_;
say "FIN: $frame->[0]";
say "RSV1: $frame->[1]";
Expand Down

0 comments on commit 3d149c6

Please sign in to comment.