EventBus class
This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
函数“on”将事件侦听器添加到事件对象,将事件函数存储在指定的事件名称下。
Signature:
typescript
declare class EventBus
declare class EventBus
Example
const eventBus = new EventBus(); eventBus.on('myEvent', () => { console.log('myEvent triggered'); });
Constructors
Constructor | Modifiers | Description |
---|---|---|
(constructor)() | (BETA) Constructs a new instance of the EventBus class |
Methods
Method | Modifiers | Description |
---|---|---|
clear(eventName) | (BETA) clear 函数从 eventObj 对象中删除事件。 | |
emit(eventName, Args) | (BETA) “emit”函数触发与特定事件名称关联的所有事件处理程序,并将任何参数传递给它们。 | |
off(eventName, fn) | (BETA) | |
on(eventName, eventFn) | (BETA) 函数“on”将事件侦听器添加到事件对象,将事件函数存储在指定的事件名称下。 |