mirror of
https://github.com/MetinSeylan/Vue-Socket.io.git
synced 2025-04-16 15:21:28 +02:00
parent
8988085bef
commit
caf4f56b10
2 changed files with 61 additions and 0 deletions
59
index.d.ts
vendored
Normal file
59
index.d.ts
vendored
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class VueSocketIO<T> implements PluginObject<T> {
|
||||||
|
constructor (options: VueSocketOptions);
|
||||||
|
install: PluginFunction<T>
|
||||||
|
}
|
|
@ -38,6 +38,8 @@
|
||||||
"@babel/preset-env": "^7.1.0",
|
"@babel/preset-env": "^7.1.0",
|
||||||
"babel-loader": "^8.0.4",
|
"babel-loader": "^8.0.4",
|
||||||
"cross-env": "^5.2.0",
|
"cross-env": "^5.2.0",
|
||||||
|
"vue": "^2.6.10",
|
||||||
|
"vuex": "^3.1.1",
|
||||||
"webpack": "^4.23.1",
|
"webpack": "^4.23.1",
|
||||||
"webpack-cli": "^3.1.2"
|
"webpack-cli": "^3.1.2"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue