Reference Source
import {EventEmitter} from 'parallax/src/events.mjs'
public class | source

EventEmitter

Class-based EventEmitter for managing custom events with pInstance-specific tracking.

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public

Map to store event listeners by pInstance and event type.

Method Summary

Public Methods
public

emit(pInstance: object, pEventName: string, pData: object)

Triggers a specified event on a specific pInstance, invoking all registered listeners.

public

off(pInstance: object, pEventName: string, pListener: Function)

Unregisters a listener for a specified event on a specific pInstance.

public

on(pInstance: object, pEventName: string, pListener: Function)

Registers a listener for a specified event on a specific pInstance.

Public Constructors

public constructor() source

Public Members

public events: WeakMap<object, Map<string, Set<Function>>> source

Map to store event listeners by pInstance and event type.

Public Methods

public emit(pInstance: object, pEventName: string, pData: object) source

Triggers a specified event on a specific pInstance, invoking all registered listeners.

Params:

NameTypeAttributeDescription
pInstance object

The instance to trigger the event on.

pEventName string

The name of the event.

pData object
  • optional

The data to pass to the event listeners.

public off(pInstance: object, pEventName: string, pListener: Function) source

Unregisters a listener for a specified event on a specific pInstance.

Params:

NameTypeAttributeDescription
pInstance object

The instance to disassociate the event from.

pEventName string

The name of the event.

pListener Function

The function to remove from the event.

public on(pInstance: object, pEventName: string, pListener: Function) source

Registers a listener for a specified event on a specific pInstance.

Params:

NameTypeAttributeDescription
pInstance object

The instance to associate the event with.

pEventName string

The name of the event.

pListener Function

The function to invoke when the event is triggered.