Permalink
Browse files

better callback examples

  • Loading branch information...
1 parent 5a7b9ae commit d5aa46c7cc35fc79adf385655e1d551c23ecbcc6 @kraih committed Dec 18, 2011
View
@@ -429,6 +429,7 @@ L<Mojo::Content> can emit the following events.
$content->on(body => sub {
my $content = shift;
+ ...
});
Emitted once all headers have been parsed and the body starts. Note that this
@@ -443,6 +444,7 @@ event is EXPERIMENTAL and might change without warning!
$content->on(read => sub {
my ($content, $chunk) = @_;
+ ...
});
Emitted when a new chunk of content arrives.
@@ -253,6 +253,7 @@ emit the following new ones.
$multi->on(part => sub {
my ($multi, $single) = @_;
+ ...
});
Emitted when a new L<Mojo::Content::Single> part starts. Note that this event
@@ -91,6 +91,7 @@ emit the following new ones.
$single->on(upgrade => sub {
my ($single, $multi) = @_;
+ ...
});
Emitted when content gets upgraded to a L<Mojo::Content::MultiPart> object.
View
@@ -149,6 +149,7 @@ Subscribe to event.
$e->on(foo => sub {
my ($e, @args) = @_;
+ ...
});
=head2 C<once>
@@ -159,6 +160,7 @@ Subscribe to event and unsubscribe again after it has been emitted once.
$e->once(foo => sub {
my ($e, @args) = @_;
+ ...
});
=head2 C<subscribers>
View
@@ -476,7 +476,6 @@ Mojo::IOLoop - Minimalistic reactor for non-blocking TCP clients and servers
# Got some data, time to write
$stream->write('HTTP/1.1 200 OK');
});
-
});
# Connect to port 3000
@@ -487,7 +486,7 @@ Mojo::IOLoop - Minimalistic reactor for non-blocking TCP clients and servers
my ($stream, $chunk) = @_;
# Process input
- say $chunk;
+ say "Input: $chunk";
});
# Write request
@@ -623,6 +622,7 @@ might change without warning!
Mojo::IOLoop->client({port => 3000} => sub {
my ($loop, $err, $stream) = @_;
+ ...
});
=head2 C<defer>
@@ -714,6 +714,7 @@ might change without warning!
Mojo::IOLoop->server({port => 3000} => sub {
my ($loop, $stream, $id) = @_;
+ ...
});
=head2 C<singleton>
@@ -177,6 +177,7 @@ L<Mojo::IOLoop::Client> can emit the following events.
$client->on(connect => sub {
my ($client, $handle) = @_;
+ ...
});
Emitted safely once the connection is established.
@@ -185,6 +186,7 @@ Emitted safely once the connection is established.
$client->on(error => sub {
my ($client, $err) = @_;
+ ...
});
Emitted safely if an error happens on the connection.
View
@@ -65,6 +65,7 @@ L<Mojo::IOLoop::Delay> can emit the following events.
$delay->on(finish => sub {
my $delay = shift;
+ ...
});
Emitted safely once the active event counter reaches zero.
@@ -294,6 +294,7 @@ L<Mojo::IOLoop::Server> can emit the following events.
$server->on(accept => sub {
my ($server, $handle) = @_;
+ ...
});
Emitted safely for each accepted connection.
@@ -209,6 +209,7 @@ L<Mojo::IOLoop::Stream> can emit the following events.
$stream->on(close => sub {
my $stream = shift;
+ ...
});
Emitted safely if the stream gets closed.
@@ -217,6 +218,7 @@ Emitted safely if the stream gets closed.
$stream->on(drain => sub {
my $stream = shift;
+ ...
});
Emitted safely once all data has been written.
@@ -225,6 +227,7 @@ Emitted safely once all data has been written.
$stream->on(error => sub {
my ($stream, $err) = @_;
+ ...
});
Emitted safely if an error happens on the stream.
@@ -233,6 +236,7 @@ Emitted safely if an error happens on the stream.
$stream->on(read => sub {
my ($stream, $chunk) = @_;
+ ...
});
Emitted safely if new data arrives on the stream.
@@ -241,6 +245,7 @@ Emitted safely if new data arrives on the stream.
$stream->on(timeout => sub {
my $stream = shift;
+ ...
});
Emitted safely if the stream has been inactive for too long and will get
@@ -251,6 +256,7 @@ without warning!
$stream->on(write => sub {
my ($stream, $chunk) = @_;
+ ...
});
Emitted safely if new data has been written to the stream.
View
@@ -172,6 +172,7 @@ L<Mojo::IOWatcher> can emit the following events.
$watcher->on(error => sub {
my ($watcher, $err) = @_;
+ ...
});
Emitted safely if an error happens.
View
@@ -121,6 +121,7 @@ L<Mojo::Log> can emit the following events.
$log->on(message => sub {
my ($log, $level, @messages) = @_;
+ ...
});
Emitted when a new message gets logged. Note that this event is EXPERIMENTAL
View
@@ -540,6 +540,7 @@ L<Mojo::Message> can emit the following events.
$message->on(finish => sub {
my $message = shift;
+ ...
});
Emitted after message building or parsing is finished.
@@ -554,6 +555,7 @@ Emitted after message building or parsing is finished.
$message->on(progress => sub {
my $message = shift;
+ ...
});
Emitted when message building or parsing makes progress.
View
@@ -101,6 +101,7 @@ L<Mojo::Server> can emit the following events.
$server->on(request => sub {
my ($server, $tx) = @_;
+ ...
});
Emitted when a request is ready and needs to be handled.
View
@@ -122,6 +122,7 @@ L<Mojo::Transaction> can emit the following events.
$tx->on(connection => sub {
my ($tx, $connection) = @_;
+ ...
});
Emitted when a connection has been assigned to transaction. Note that this
@@ -131,6 +132,7 @@ event is EXPERIMENTAL and might change without warning!
$tx->on(finish => sub {
my $tx = shift;
+ ...
});
Emitted when transaction is finished.
@@ -139,6 +141,7 @@ Emitted when transaction is finished.
$tx->on(resume => sub {
my $tx = shift;
+ ...
});
Emitted when transaction is resumed.
@@ -299,6 +299,7 @@ can emit the following new ones.
$tx->on(request => sub {
my $tx = shift;
+ ...
});
Emitted when a request is ready and needs to be handled.
@@ -312,6 +313,7 @@ Emitted when a request is ready and needs to be handled.
$tx->on(upgrade => sub {
my ($tx, $ws) = @_;
+ ...
});
Emitted when transaction gets upgraded to a L<Mojo::Transaction::WebSocket>
@@ -356,6 +356,7 @@ and can emit the following new ones.
$ws->on(frame => sub {
my ($ws, $frame) = @_;
+ ...
});
Emitted when a WebSocket frame has been received.
@@ -371,6 +372,7 @@ Emitted when a WebSocket frame has been received.
$ws->on(message => sub {
my ($ws, $message) = @_;
+ ...
});
Emitted when a complete WebSocket message has been received.
View
@@ -637,6 +637,7 @@ L<Mojo::UserAgent> can emit the following events.
$ua->on(start => sub {
my ($ua, $tx) = @_;
+ ...
});
Emitted whenever a new transaction is about to start, this includes

2 comments on commit d5aa46c

Collaborator

marcusramberg replied Dec 18, 2011

there will be dots!

Contributor

memowe replied Dec 18, 2011

They look like customers waiting in line to download the latest version from CPAN.

Please sign in to comment.