Note: This module is not part of the public API, and is subject to change.

Module: j5e/event

Description

event module - Houses event related mixins


Class: Emitter

Provides an event base class for devices. It is not meant to be used directly.

Constructor

new Emitter()

Methods

Emitter.on

Create an event listener

emitter.on(event, listener);

Parameters

Name
Type
Description
event
(required)
string

Description:
The name of the event to listen for

listener
(required)
function

Description:
A callback to run when the event is fired.


Emitter.removeListener

Remove an event listener

emitter.removeListener(event, listener);

Parameters

Name
Type
Description
event
(required)
string

Description:
The name of the event that we are removing a listener from

listener
(required)
function

Description:
The callback that we are removing


Emitter.emit

Note: This method is not part of the public API, and is subject to change.

Emit an event

emitter.emit(event);

Parameters

Name
Type
Description
event
(required)
string

Description:
The name of the event to emit


Emitter.once

Create an event listener that will only fire one time.

emitter.once(event, listener);

Parameters

Name
Type
Description
event
(required)
string

Description:
The name of the event to listen for

listener
(required)
function

Description:
A callback to run when the event is fired.