Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

mojo::eventemitter(3pm) [debian man page]

Mojo::EventEmitter(3pm) 				User Contributed Perl Documentation				   Mojo::EventEmitter(3pm)

NAME
Mojo::EventEmitter - Event emitter base class SYNOPSIS
package Cat; use Mojo::Base 'Mojo::EventEmitter'; # Emit events sub poke { my $self = shift; $self->emit(roar => 3); } package main; # Subscribe to events my $tiger = Cat->new; $tiger->on(roar => sub { my ($tiger, $times) = @_; say 'RAWR!' for 1 .. $times; }); $tiger->poke; DESCRIPTION
Mojo::EventEmitter is a simple base class for event emitting objects. METHODS
Mojo::EventEmitter inherits all methods from Mojo::Base and implements the following new ones. "emit" $e = $e->emit('foo'); $e = $e->emit('foo', 123); Emit event. "emit_safe" $e = $e->emit_safe('foo'); $e = $e->emit_safe('foo', 123); Emit event safely and emit "error" event on failure. "has_subscribers" my $success = $e->has_subscribers('foo'); Check if event has subscribers. "on" my $cb = $e->on(foo => sub {...}); Subscribe to event. $e->on(foo => sub { my ($e, @args) = @_; ... }); "once" my $cb = $e->once(foo => sub {...}); Subscribe to event and unsubscribe again after it has been emitted once. $e->once(foo => sub { my ($e, @args) = @_; ... }); "subscribers" my $subscribers = $e->subscribers('foo'); All subscribers for event. # Unsubscribe last subscriber $e->unsubscribe(foo => $e->subscribers('foo')->[-1]); "unsubscribe" $e = $e->unsubscribe('foo'); $e = $e->unsubscribe(foo => $cb); Unsubscribe from event. DEBUGGING
You can set the "MOJO_EVENTEMITTER_DEBUG" environment variable to get some advanced diagnostics information printed to "STDERR". MOJO_EVENTEMITTER_DEBUG=1 SEE ALSO
Mojolicious, Mojolicious::Guides, <http://mojolicio.us>. perl v5.14.2 2012-09-05 Mojo::EventEmitter(3pm)

Check Out this Related Man Page

Mojo::Asset(3pm)					User Contributed Perl Documentation					  Mojo::Asset(3pm)

NAME
Mojo::Asset - HTTP 1.1 content storage base class SYNOPSIS
use Mojo::Base 'Mojo::Asset'; DESCRIPTION
Mojo::Asset is an abstract base class for HTTP 1.1 content storage. ATTRIBUTES
Mojo::Asset implements the following attributes. "end_range" my $end = $asset->end_range; $asset = $asset->end_range(8); Pretend file ends earlier. "start_range" my $start = $asset->start_range; $asset = $asset->start_range(0); Pretend file starts later. METHODS
Mojo::Asset inherits all methods from Mojo::EventEmitter and implements the following new ones. "add_chunk" $asset = $asset->add_chunk('foo bar baz'); Add chunk of data to asset, meant to be overloaded in a subclass. "contains" my $position = $asset->contains('bar'); Check if asset contains a specific string, meant to be overloaded in a subclass. "get_chunk" my $chunk = $asset->get_chunk($offset); Get chunk of data starting from a specific position, meant to be overloaded in a subclass. "is_file" my $false = $asset->is_file; False. "move_to" $asset = $asset->move_to('/home/sri/foo.txt'); Move asset data into a specific file, meant to be overloaded in a subclass. "size" my $size = $asset->size; Size of asset data in bytes, meant to be overloaded in a subclass. "slurp" my $string = $asset->slurp; Read all asset data at once. Meant to be overloaded in a subclass. SEE ALSO
Mojolicious, Mojolicious::Guides, <http://mojolicio.us>. perl v5.14.2 2012-09-05 Mojo::Asset(3pm)
Man Page