跳到主要内容
版本:0.9.0-beta.2

Class: EventEmitter

molecule.event.EventEmitter

Constructors

constructor

new EventEmitter()

Properties

_events

Private _events: Map<string, Function[]>

Defined in

src/common/event/eventEmitter.ts:2

Methods

assignEvent

assignEvent<T>(name, callback): void

Type parameters

Name
T

Parameters

NameType
namestring
callbackFunction

Returns

void

Defined in

src/common/event/eventEmitter.ts:46


count

count(name): number

Parameters

NameType
namestring

Returns

number

Defined in

src/common/event/eventEmitter.ts:4


emit

emit(name, ...args): void

Parameters

NameType
namestring
...argsany[]

Returns

void

Defined in

src/common/event/eventEmitter.ts:9


subscribe

subscribe(name, callback): void

Parameters

NameType
namestring | string[]
callbackFunction

Returns

void

Defined in

src/common/event/eventEmitter.ts:18


unsubscribe

unsubscribe(name): void

Unsubscribe the specific event by the name

TODO: The unsubscribe method delete the all events via the name directly, the developer use the subscribe method could register many callbacks, so if the developer only want to delete the specific callback by the name, this method is no work.

Parameters

NameTypeDescription
namestring | string[]The removed event name

Returns

void

Defined in

src/common/event/eventEmitter.ts:36