UNPKG

kitten-cloud-function

Version:

用于编程猫源码云功能(云变量、云列表等)的客户端工具

30 lines (29 loc) 1.04 kB
/** * 信号,用于向外界发送消息。 */ export declare class Signal<T> { slots: ((message: T) => void)[]; constructor(); /** * 连接一个消息接收函数,当有消息被发送时,该函数将被调用。 * * @param slot 接收函数 */ connect(this: this, slot: (message: T) => void): void; /** * 断开一个消息接收函数,使其不再接收消息。如果该函数不在接收列表中,则什么也不做。 * * @param slot 要断开的接收函数 */ disconnect(this: this, slot: (message: T) => void): void; clear(this: this): void; isEmpty(this: this): boolean; emit(this: this, message: T): void; /** * 等待消息被发送或超时。 * * @param timeout 超时时间(毫秒),`0` 表示永不超时。 * @returns 一个 Promise 对象,当收到消息时,该对象将被 resolve,如果等待超时,则该对象将被 reject。 */ wait(this: this, timeout?: number): Promise<T>; }