Home Reference Source
import EventHandler from 'potassium-es/src/EventHandler.js'
public class | source

EventHandler

Indirect Subclass:

DataCollection, DataModel, src/Engine.js~FallbackPortalDisplay, FlatDisplay, src/Engine.js~WebVRDisplay, src/Engine.js~WebXRDisplay

EventHandler is the base class that implements event distribution

Member Summary

Public Members
public get

listeners: EventListener[]: *

Method Summary

Public Methods
public

addListener(callback: function(eventName: string, eventSource: EventHandler), eventName: Object | Symbol, once: bool)

public
public

removeListener(callback: *, eventName: undefined)

public

trigger(eventName: *, params: ...*)

Send an event to listeners

Public Members

public get listeners: EventListener[]: * source

Return:

EventListener[]

Public Methods

public addListener(callback: function(eventName: string, eventSource: EventHandler), eventName: Object | Symbol, once: bool) source

Params:

NameTypeAttributeDescription
callback function(eventName: string, eventSource: EventHandler)

often includes more parameters that are specific to the event

eventName Object | Symbol
  • optional
  • default: EventHandler.ALL_EVENTS

a string or Symbol indicating the event to watch, defaults to ALL_EVENTS

once bool
  • optional
  • default: false

If true then the listener is removed after receiving one event

public clearListeners() source

public removeListener(callback: *, eventName: undefined) source

Params:

NameTypeAttributeDescription
callback *
eventName undefined
  • optional
  • default: undefined

public trigger(eventName: *, params: ...*) source

Send an event to listeners

Params:

NameTypeAttributeDescription
eventName *
params ...*