Skip to main content
Version: 23.2.0

EventEmitter.once() 方法

¥EventEmitter.once() method

on 类似,但监听器只会被触发一次,然后就会被删除。

¥Like on but the listener will only be fired once and then it will be removed.

签名

¥Signature

class EventEmitter {
once<Key extends keyof EventsWithWildcard<Events>>(
type: Key,
handler: Handler<EventsWithWildcard<Events>[Key]>
): this;
}

参数

¥Parameters

范围

类型

描述

type

你想听的活动

handler

处理程序<EventsWithWildcard<事件>[按键]>

事件发生时运行的处理函数

Returns:

this

this 使你能够链接方法调用。

¥this to enable you to chain method calls.