-
Notifications
You must be signed in to change notification settings - Fork 499
/
index.d.ts
63 lines (57 loc) · 1.49 KB
/
index.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
import SocketIOClient from "socket.io-client";
import {
DefaultComputed,
DefaultData,
DefaultMethods,
DefaultProps,
PropsDefinition,
} from "vue/types/options";
import { Vue } from "vue/types/vue";
import { PluginFunction, PluginObject } from "vue";
import { Store } from "vuex";
interface socketHandler<T> {
(this: T, ...args: any[]): void
}
interface Sockets<V> {
[key: string]: socketHandler<V>
}
declare module 'vue/types/vue' {
interface Vue {
$socket: SocketIOClient.Socket,
sockets: {
subscribe(eventName: string, handler: socketHandler<Vue>): void,
unsubscribe(eventName: string): void,
}
}
}
declare module 'vue/types/options' {
interface ComponentOptions<
V extends Vue,
Data=DefaultData<V>,
Methods=DefaultMethods<V>,
Computed=DefaultComputed,
PropsDef=PropsDefinition<DefaultProps>,
Props=DefaultProps> {
sockets?: Sockets<V>
}
}
export interface VueSocketOptions {
debug?: boolean;
connection: string | SocketIOClient.Socket,
vuex?: {
store?: Store<any>,
actionPrefix?: string,
mutationPrefix?: string,
options?: {
useConnectionNamespace?: boolean
}
},
// type declarations for optional options
options?:{
path?: string;
}
}
export default class VueSocketIO<T> implements PluginObject<T> {
constructor (options: VueSocketOptions);
install: PluginFunction<T>
}