Skip to Content
ClassesFEventRegistry

类: FEventRegistry

构造函数

构造函数

new FEventRegistry(): FEventRegistry

返回

FEventRegistry

方法

addEvent()

addEvent<T>(event, callback): IDisposable

Add an event listener

类型参数

类型参数
T extends keyof IEventParamConfig

参数

参数类型描述
eventTkey of event
callback(params) => voidcallback when event triggered

返回

IDisposable

The Disposable instance, for remove the listener

示例

univerAPI.addEvent(univerAPI.Event.LifeCycleChanged, (params) => { const { stage } = params; console.log('life cycle changed', params); });

fireEvent()

fireEvent<T>(event, params): boolean

Fire an event, used in internal only.

类型参数

类型参数
T extends keyof IEventParamConfig

参数

参数类型描述
eventTkey of event
paramsIEventParamConfig[T]params of event

返回

boolean

should cancel

示例

this.fireEvent(univerAPI.Event.LifeCycleChanged, params);

registerEventHandler()

registerEventHandler(event, handler): IDisposable

参数

参数类型
eventstring
handler() => any

返回

IDisposable


removeEvent()

removeEvent<T>(event, callback): void

类型参数

类型参数
T extends keyof IEventParamConfig

参数

参数类型
eventT
callback(params) => void

返回

void