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