UNPKG

1.7 kBJavaScriptView Raw
1// for document only
2// SDK uses https://www.npmjs.com/package/eventemitter3
3
4/**
5 * @class EventEmitter
6 * @private
7 */
8
9/**
10 * 给指定的 event 添加监听器,并将该监听器置于监听器列表的末位。该方法不会检查是否已经添加过该监听器。重复添加相同的 event 和 listener 会导致该事件和监听器被重复触发。
11 *
12 * @function on
13 * @memberof EventEmitter.prototype
14 * @param {String|Symbol} event The event name.
15 * @param {Function} listener The listener function.
16 * @param {Mixed} [context=this] The context to invoke the listener with.
17 * @returns {this} self.
18 */
19
20/**
21 * 为 event 事件添加一个一次性的监听器,该事件第一次触发之后就会被注销。
22 *
23 * @function once
24 * @memberof EventEmitter.prototype
25 * @param {String|Symbol} event The event name.
26 * @param {Function} listener The listener function.
27 * @param {Mixed} [context=this] The context to invoke the listener with.
28 * @returns {this} self.
29 */
30
31/**
32 * 移除 event 事件的监听器列表中的 listener。
33 *
34 * @function off
35 * @memberof EventEmitter.prototype
36 * @param {String|Symbol} event The event name.
37 * @param {Function} [listener] Only remove the listeners that match this function.
38 * @param {Mixed} [context] Only remove the listeners that have this context.
39 * @param {Boolean} [once] Only remove one-time listeners.
40 * @returns {this} self.
41 */
42
43/**
44 * 依次调用 event 事件的监听器列表中的 listener。
45 *
46 * @function emit
47 * @memberof EventEmitter.prototype
48 * @param {String|Symbol} event The event name.
49 * @param {Mixed} [...arg] payloads
50 * @returns {Boolean} `true` if the event had listeners, else `false`.
51 */