forked from jbaroudi/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
offline-js.d.ts
64 lines (58 loc) · 2.77 KB
/
offline-js.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Type definitions for Offline 0.7.14
// Project: https://github.com/HubSpot/offline
// Definitions by: Chris Wrench <https://github.com/cgwrench>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare var Offline: {
options: OfflineOptions;
check: () => void;
state: string;
on(event: "up", handler: (e: Event) => any, context?: any): void;
on(event: "down", handler: (e: Event) => any, context?: any): void;
on(event: "confirmed-up", handler: (e: Event) => any, context?: any): void;
on(event: "confirmed-down", handler: (e: Event) => any, context?: any): void;
on(event: "checking", handler: (e: Event) => any, context?: any): void;
on(event: "reconnect:started", handler: (e: Event) => any, context?: any): void;
on(event: "reconnect:stopped", handler: (e: Event) => any, context?: any): void;
on(event: "reconnect:tick", handler: (e: Event) => any, context?: any): void;
on(event: "reconnect:connecting", handler: (e: Event) => any, context?: any): void;
on(event: "reconnect:failure", handler: (e: Event) => any, context?: any): void;
on(event: "requests:flush", handler: (e: Event) => any, context?: any): void;
on(event: "requests:hold", handler: (e: Event) => any, context?: any): void;
on(event: string, handler: (e: Event) => any, context?: any): void;
off(event: "up", handler?: (e: Event) => any): void;
off(event: "down", handler?: (e: Event) => any): void;
off(event: "confirmed-up", handler?: (e: Event) => any): void;
off(event: "confirmed-down", handler?: (e: Event) => any): void;
off(event: "checking", handler?: (e: Event) => any): void;
off(event: "reconnect:started", handler?: (e: Event) => any): void;
off(event: "reconnect:stopped", handler?: (e: Event) => any): void;
off(event: "reconnect:tick", handler?: (e: Event) => any): void;
off(event: "reconnect:connecting", handler?: (e: Event) => any): void;
off(event: "reconnect:failure", handler?: (e: Event) => any): void;
off(event: "requests:flush", handler?: (e: Event) => any): void;
off(event: "requests:hold", handler?: (e: Event) => any): void;
off(event: string, handler?: (e: Event) => any): void;
};
interface OfflineOptions {
// TODO Should these types be `boolean|Function`?
// The project documentation is not clear here.
checkOnLoad?: boolean;
interceptRequests?: boolean;
requests?: boolean;
game?: boolean;
checks?: OfflineChecks;
reconnect: {
initialDelay: number;
delay: number;
};
}
interface OfflineChecks {
// TODO "xhr" and "image" probably have different options.
// However, this is not stated in the project documentation.
xhr?: OfflineCheck;
image?: OfflineCheck;
active?: string;
}
interface OfflineCheck {
url: string;
}