Event Listener
Reading needs 1 minutes
Remove all event listeners
off(): this;
Returns:
Type: this
Description: Graph 实例
Remove all listeners for the specified event
off(eventName: string): this;
Parameter | Type | Description |
---|---|---|
eventName | string | 事件名称 |
Returns:
Type: this
Description: Graph 实例
Remove event listener
off(eventName: string, callback: (...args: any[]) => void): this;
Parameter | Type | Description |
---|---|---|
eventName | string | 事件名称 |
callback | (...args: any[]) => void | 回调函数 |
Returns:
Type: this
Description: Graph 实例
Listen to events
on<T extends IEvent = IEvent>(eventName: string, callback: (event: T) => void, once?: boolean): this;
Parameter | Type | Description |
---|---|---|
eventName | string | 事件名称 |
callback | (event: T) => void | 回调函数 |
once | boolean | 是否只监听一次 |
Returns:
Type: this
Description: Graph 实例
Listen to events once
once<T extends IEvent = IEvent>(eventName: string, callback: (event: T) => void): this;
Parameter | Type | Description |
---|---|---|
eventName | string | 事件名称 |
callback | (event: T) => void | 回调函数 |
Returns:
Type: this
Description: Graph 实例