MooX::Role::EventEmitter(3pm)

NAME
MooX::Role::EventEmitter - Event emitter role

SYNOPSIS
  package My::Thing;
  use 5.020;
  use feature 'signatures';
  no warnings 'experimental::signatures';
  use Moo 2;
  with 'MooX::Role::EventEmitter';

  sub event_received( $self, $ev ) {
      $self->emit( myevent => $ev );
  }

  # ... later, in your client

  package main;
  my $foo = My::Thing->new();
  $foo->on( myevent => sub( $ev ) {
      say "I receivend an event";
  });

METHODS

  "$obj->emit $name, @args"
Emit an event

  "$obj->has_subscribers $name"
Check if an event has subscribers.

  "$obj->on $name, @args"
  my $cb = $obj->on( myevent => sub { ... });

Subscribe to an event.

  "$obj->once $name, @args"
  my $cb = $obj->once( myevent => sub { ... });

Subscribe to an event for just one event.

  "$obj->subscribers( $name )"
  my $s = $obj->subscribers( 'myevent' );

Return an arrayref of the subscribers for an event.

  "$obj->unsubscribe( $name => $cb )"
  $obj->unsubscribe('myevent', $cb); # a specific callback
  $obj->unsubscribe('myevent');      # all callbacks

Unsubscribe from event.

SEE ALSO
Mojo::EventEmitter - the module this API is based on