WIP
This commit is contained in:
+9
-19
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user