This commit is contained in:
Sacha Weatherstone
2021-08-02 17:19:56 +10:00
parent 8f65769377
commit c543a4ef5c
36 changed files with 2199 additions and 4513 deletions
+9 -19
View File
@@ -1,24 +1,14 @@
import type { Protobuf } from '@meshtastic/meshtasticjs';
import { configureStore, createSlice } from '@reduxjs/toolkit';
import { configureStore } from '@reduxjs/toolkit';
const nodesSlice = createSlice({
name: 'nodes',
initialState: {
members: [],
},
reducers: {
addMember: (state: Protobuf.NodeInfo[], node: Protobuf.NodeInfo) => {
// Redux Toolkit allows us to write "mutating" logic in reducers. It
// doesn't actually mutate the state because it uses the Immer library,
// which detects changes to a "draft state" and produces a brand new
// immutable state based off those changes
state.push(node);
},
},
});
import appSlice from './slices/appSlice';
import meshtasticSlice from './slices/meshtasticSlice';
export default configureStore({
export const store = configureStore({
reducer: {
nodes: nodesSlice.reducer,
app: appSlice,
meshtastic: meshtasticSlice,
},
});
export type RootState = ReturnType<typeof store.getState>;
export type AppDispatch = typeof store.dispatch;