Skip to content

Commit 68186ed

Browse files
committedJun 23, 2014
+ Initial commit
1 parent f6208ec commit 68186ed

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed
 

‎README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
typescript-server-sent-events
22
=============================
33

4-
TypeScript definitions for Server-Sent Events
4+
TypeScript definitions for [Server-Sent Events](http://dev.w3.org/html5/eventsource/)

‎sse.d.ts

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Type definitions for Server-Sent Events
2+
// Specification: http://dev.w3.org/html5/eventsource/
3+
// Definitions by: Yannik Hampe <https://github.com/yankee42>
4+
5+
declare var EventSource : sse.IEventSourceStatic;
6+
7+
declare module sse {
8+
9+
enum ReadyState {CONNECTING = 0, OPEN = 1, CLOSED = 2}
10+
11+
interface IEventSourceStatic extends EventTarget {
12+
new (url: string, eventSourceInitDict?: IEventSourceInit);
13+
url: string;
14+
withCredentials: boolean;
15+
CONNECTING: ReadyState; // constant, always 0
16+
OPEN: ReadyState; // constant, always 1
17+
CLOSED: ReadyState; // constant, always 2
18+
readyState: ReadyState;
19+
onopen: Function;
20+
onmessage: (event: IOnMessageEvent) => void;
21+
onerror: Function;
22+
close: () => void;
23+
}
24+
25+
interface IEventSourceInit {
26+
withCredentials?: boolean;
27+
}
28+
29+
interface IOnMessageEvent {
30+
data: string;
31+
}
32+
}

0 commit comments

Comments
 (0)
Please sign in to comment.