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
|
import { createSlice } from '@reduxjs/toolkit';
const { reducer, actions } = createSlice({
name: 'session',
initialState: {
server: null,
user: null,
socket: null,
positions: {},
},
reducers: {
updateServer(state, action) {
state.server = action.payload;
},
updateUser(state, action) {
state.user = action.payload;
},
updateSocket(state, action) {
state.socket = action.payload;
},
updatePositions(state, action) {
action.payload.forEach((position) => state.positions[position.deviceId] = position);
},
},
});
export { actions as sessionActions };
export { reducer as sessionReducer };
|