GeezerVison is showing maxgraph.github.io — EventSource | @maxgraph/core
Base class for objects that dispatch named events.
To create a subclass that inherits from EventSource, the following code is used:
class MyClass extends EventSource {
// implement the logic here
};
Known Subclasses:
Constructors
constructor
-
new EventSource(eventSource?: EventTarget | null): EventSource
Parameters
- eventSource: EventTarget | null = null
Returns EventSource
Properties
eventListeners
eventListeners: EventListenerObject[] = []
Holds the event names and associated listeners in an array. The array
contains the event name followed by the respective listener for each
registered listener.
eventsEnabled
eventsEnabled: boolean = true
Specifies if events can be fired. Default is true.
eventSource
eventSource: EventTarget | null = null
Optional source for events.
Methods
addListener
-
addListener(name: string, funct: Function): void
Binds the specified function to the given event name. If no event name
is given, then the listener is registered for all events.
The parameters of the listener are the sender and an EventObject.
Parameters
- name: string
- funct: Function
Returns void
destroy
-
Clears all registered event listeners.
Subclasses with a destroy method should call super.destroy() at the end
of their own cleanup to ensure no stale listeners remain.
Returns void
fireEvent
-
fireEvent(evt: EventObject, sender?: EventTarget | null): void
Dispatches the given event to the listeners which are registered for the event.
The sender argument is optional.
The current execution scope ("this") is used for the listener invocation.
Example:
fireEvent(new EventObject("eventName", key1, val1, .., keyN, valN))
Parameters
- evt: EventObject
- sender: EventTarget | null = null
Optional sender to be passed to the listener. Default value is the return value of getEventSource.
Returns void
getEventSource
-
getEventSource(): EventTarget | null
Returns EventTarget | null
isEventsEnabled
-
isEventsEnabled(): boolean
removeListener
-
removeListener(funct: Function): void
setEventsEnabled
-
setEventsEnabled(value: boolean): void
setEventSource
-
setEventSource(value: EventTarget | null): void
Parameters
- value: EventTarget | null
Returns void
On This Page
Constructors
Properties
Methods