Query: mojo::eventemitter
OS: debian
Section: 3pm
Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar
Mojo::EventEmitter(3pm) User Contributed Perl Documentation Mojo::EventEmitter(3pm)NAMEMojo::EventEmitter - Event emitter base classSYNOPSISpackage 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;DESCRIPTIONMojo::EventEmitter is a simple base class for event emitting objects.METHODSMojo::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.DEBUGGINGYou can set the "MOJO_EVENTEMITTER_DEBUG" environment variable to get some advanced diagnostics information printed to "STDERR". MOJO_EVENTEMITTER_DEBUG=1SEE ALSOMojolicious, Mojolicious::Guides, <http://mojolicio.us>. perl v5.14.2 2012-09-05 Mojo::EventEmitter(3pm)
Related Man Pages |
---|
mojo::base(3pm) - debian |
mojo::server(3pm) - debian |
mojo::server::cgi(3pm) - debian |
mojo::server::psgi(3pm) - debian |
mojo::upload(3pm) - debian |
Similar Topics in the Unix Linux Community |
---|
perl function call tracking |
Realtime And Wrong Time |
Funny things from FunnyJunk |
Simple awk question |
Tiger Woods Wins His 15th Major Championship and his 5th Masters. |