2019-06-30 00:14:32 +01:00
|
|
|
import { Action, action } from 'easy-peasy';
|
2019-06-30 00:57:11 +01:00
|
|
|
import { Websocket } from '@/plugins/Websocket';
|
2019-06-30 00:14:32 +01:00
|
|
|
|
|
|
|
export interface SocketState {
|
2019-06-30 00:57:11 +01:00
|
|
|
instance: Websocket | null;
|
2019-06-30 00:14:32 +01:00
|
|
|
connected: boolean;
|
2019-06-30 00:57:11 +01:00
|
|
|
setInstance: Action<SocketState, Websocket | null>;
|
2019-06-30 00:14:32 +01:00
|
|
|
setConnectionState: Action<SocketState, boolean>;
|
|
|
|
}
|
|
|
|
|
|
|
|
const socket: SocketState = {
|
|
|
|
instance: null,
|
|
|
|
connected: false,
|
|
|
|
setInstance: action((state, payload) => {
|
|
|
|
state.instance = payload;
|
|
|
|
}),
|
|
|
|
setConnectionState: action((state, payload) => {
|
|
|
|
state.connected = payload;
|
|
|
|
}),
|
|
|
|
};
|
|
|
|
|
|
|
|
export default socket;
|