NAME

Mojo::Events - Dispatch and handle sync/async events in Mojolicious

SYNOPSIS

use Mojo::Events;

my $events = Mojo::Events->new(app => $app, namespaces => ['Listeners::Namespace']);

$events->dispatcher->dispatch(say => 'Hello!');

DESCRIPTION

Mojo::Events is a very basic implementation for events/listeners

ATTRIBUTES

Mojo::Events inherits all attributes from Mojo::Base.

METHODS

Mojo::Events inherits all methods from Mojo::Base and implements the following new ones.

new

my $events = Mojo::Events->new(app => $app, namespaces => ['Listeners::Namespace']);

Events manipulator object.

dispatcher

my $dispatcher = $events->dispatcher;

# dispatch an event
$dispatcher->dispatch(event_name => (<event args>));

# register a new listener
$dispatcher->register(My::Custom::Listener->new(app => $mojolicious));

Events dispatcher.

SEE ALSO

Mojolicious, Mojolicious::Guides, https://mojolicious.org.