Last updated

API / geotoolkit / util / EventDispatcher / EventDispatcher

Class: EventDispatcher

util.EventDispatcher.EventDispatcher

Defines sender of the events. This class implements a dispatcher/listeners pattern. It's inherited by many classes of the toolkit that requires to send events.
Listeners are callbacks(functions) that can be added and removed at any time. Those will be notified when the corresponding event-type is fired on this object.

Hierarchy

Implements

Table of contents

Constructors
Methods

Contents

Constructors

new EventDispatcher()

new EventDispatcher()

Methods

dispose

dispose(): void

Dispose.

Returns

void

Implementation of

IDisposable.dispose


getClassName

getClassName(): string

Returns

string


hasEventListener

hasEventListener(type, callback?): boolean

Check if a list of event listeners for this type contains this listener

Parameters

Name Type Description
typestringtype of event or property
Optional callbackFunctionto be called, if null, check if any callback is registered

Returns

boolean


isDisposed

isDisposed(): boolean

Returns whether this object has been disposed

Returns

boolean


isSilent

isSilent(): boolean

Return true if the event dispatcher doesn't notify any events

Returns

boolean


notify

notify(type, source, args?): EventDispatcher

Notify listeners

Parameters

Name Type Description
typestringevent types
sourceanyof the event
Optional argsanyarguments of the event

Returns

EventDispatcher

this


off

off(type?, callback?): EventDispatcher

Detach listener on event. Calling .off() with no arguments removes all attached listeners. Calling .off(type) with no callback removes all attached listeners for specific type.

Parameters

Name Type Description
Optional typestringtype of the event
Optional callbackEventListenerfunction to be called

Returns

EventDispatcher

this

off<E>(type, callback): EventDispatcher

Type parameters

NameType
Eextends string

Parameters

Name Type
typeE
callback(eventType: E, sender: EventDispatcher, args: EventMap[E]) => void

Returns

EventDispatcher


on

on(type, callback, options?): EventDispatcher

Attach listener on event that will be called whenever the specified event is delivered to the target

If the callback function is already in the list of event listeners for this target, the function is not added a second time.

If a particular anonymous function is in the list of event listeners registered for a certain target, and then later in the code, an identical anonymous function is given in an "on" call, the second function will also be added to the list of event listeners for that target.

Parameters

Name Type Description
typestringtype of event or property
callbackEventListenerto be called
Optional optionsOptionsoptions of subscription

Returns

EventDispatcher

this

on<E>(type, callback, options?): EventDispatcher

Type parameters

NameType
Eextends string

Parameters

Name Type
typeE
callback(eventType: E, sender: EventDispatcher, args: EventMap[E]) => void
Optional optionsOptions

Returns

EventDispatcher


setSilent

setSilent(bool): EventDispatcher

Set silent mode

Parameters

Name Type Description
boolbooleanflag to enable silent mode

Returns

EventDispatcher

this


getClassName

Static getClassName(): string

Returns

string