Skip to content
No description, website, or topics provided.
  1. Other 100.0%
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.


Type Name Latest commit message Commit time
Failed to load latest commit information.


An extendable JS like event emitter but way more fun. Can use supplies or channels and is basically just some syntax sugar on already implemented Perl6 features.


Out of the box functionality

Single thread

Event::Emitter uses a Supply in the back end

use Event::Emitter;

my Event::Emitter $e .= new;

# hey, i work with regex
$e.on(/^^ "Some regex"/, -> $data {
  qw<do something with your $data here>;

# your own callables to match events
my $event = { 'some flag' => 3, 'some other flag' => 5 };
$e.on({ $event<some flag> // Nil eq $*STATE }, -> $data {
  qw<do something with your $data here>;

# plain ol strings, just like mom used to make
$e.on('some str', -> $data {
  qw<do something with your $data here>;

# runs the some str listener
$e.emit('some str', @(1 .. 5)); 

# runs the regex because it matches the regex;
$e.emit('Some regex', { conn => IO::Socket::INET }); 

$e.emit({ 'some flag' => 5 }, { });


Event::Emitter uses a Channel in the back end

use Event::Emitter;

my Event::Emitter $e .= new(:threaded);

Rolling your own Event::Emitter

Want to make your own receiver/emitter? Here's a template

Your new .pm6 file

use Event::Emitter::Role::Handler;

unit class My::Own::Emitter does Event::Emitter::Role::Handler;

method on($event, $data) {
  qw<do your thing>;

method emit($event, $data?) {
  qw<do your thing here>;

Later in your .pl6

use Event::Emitter;

my $e =<My::Own::Emitter>);


Free for all.

You can’t perform that action at this time.