Created
September 23, 2017 02:13
-
-
Save ashwanthkumar/73fc6f0a0e782ddcf4b81179f62f2839 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Type declaration for npm package https://www.npmjs.com/package/sse-nodejs | |
*/ | |
declare module "sse-nodejs" { | |
import { OutgoingMessage } from "http"; | |
function SSE(response: OutgoingMessage, options?: Object): SSE.ServerSendEvent; | |
namespace SSE { | |
/** | |
* ServerSendEvent wraps a response object from http and exposes | |
* a bunch of methods to send ServerSendEvent to the client. | |
*/ | |
export class ServerSendEvent { | |
constructor(response: OutgoingMessage, options?: Object); | |
/** | |
* send data only (message on server sent events) | |
* @param data | |
*/ | |
send(data: string | number | Object): void; | |
/** | |
* remove an event after timeout, if no timeout it will remove immediately | |
* | |
* @param name name of the event | |
* @param time time after which the event will be removed | |
*/ | |
removeEvent(name: string, time?: number): void; | |
/** | |
* send data after timeInterval if no timeInterval send once (data can be a function) | |
* | |
* @param name name of the channel | |
* @param data actual data that needs to be sent | |
*/ | |
sendEvent(name: string, data: Object | Function, time?: number): void; | |
/** | |
* listen event 'close' | |
* @param fn | |
*/ | |
disconnect(fn: Function): void; | |
private sendInterval(name: string, fn: Function, time?: number): void; | |
} | |
} | |
export = SSE; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment