Introducing redux to manage tracks.
This commit is contained in:
1 parent
b01870d234
commit
5867338836
7 files changed
+307
-44
No files matched your search
@@ -0,0 +1,28 @@
|
||||
import { createSlice } from '@reduxjs/toolkit';
|
||||
|
||||
const initialState: any = {
|
||||
current: {
|
||||
$: {},
|
||||
trk: [
|
||||
{
|
||||
trkseg: [{ trkpt: [] }],
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
const slice = createSlice({
|
||||
name: 'gpx',
|
||||
initialState: initialState,
|
||||
reducers: {
|
||||
appendTrkpt(state, action) {
|
||||
state[action.payload.trkKey].trk[0].trkseg[0].trkpt.push(
|
||||
action.payload.trkpt
|
||||
);
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const gpxActions = slice.actions;
|
||||
|
||||
export default slice.reducer;
|
||||
@@ -0,0 +1,9 @@
|
||||
import { configureStore } from '@reduxjs/toolkit';
|
||||
|
||||
import gpxReducer from './gpx';
|
||||
|
||||
const store = configureStore({
|
||||
reducer: { gpx: gpxReducer },
|
||||
});
|
||||
|
||||
export default store;
|
||||
Reference in new issue
Block a user