mirror of
https://github.com/MrUnknownDE/panel.git
synced 2026-04-22 16:23:45 +02:00
Switch to a context store for server stuff to better support things in the future
This commit is contained in:
22
resources/scripts/state/server/socket.ts
Normal file
22
resources/scripts/state/server/socket.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { Action, action } from 'easy-peasy';
|
||||
import { Websocket } from '@/plugins/Websocket';
|
||||
|
||||
export interface SocketStore {
|
||||
instance: Websocket | null;
|
||||
connected: boolean;
|
||||
setInstance: Action<SocketStore, Websocket | null>;
|
||||
setConnectionState: Action<SocketStore, boolean>;
|
||||
}
|
||||
|
||||
const socket: SocketStore = {
|
||||
instance: null,
|
||||
connected: false,
|
||||
setInstance: action((state, payload) => {
|
||||
state.instance = payload;
|
||||
}),
|
||||
setConnectionState: action((state, payload) => {
|
||||
state.connected = payload;
|
||||
}),
|
||||
};
|
||||
|
||||
export default socket;
|
||||
Reference in New Issue
Block a user