based redux
This commit is contained in:
1 parent
5f853696ab
commit
b0572cb63d
8 files changed
+145
-42
No files matched your search
+38
-9
@@ -1,10 +1,39 @@
|
||||
import unistore from 'unistore'
|
||||
import { createStore, combineReducers } from 'redux'
|
||||
import { configureStore, createSlice } from '@reduxjs/toolkit'
|
||||
|
||||
export default function createStore() {
|
||||
return unistore({
|
||||
bundles: [],
|
||||
offers: [],
|
||||
user: null,
|
||||
ws: null,
|
||||
});
|
||||
};
|
||||
export const userState = createSlice({
|
||||
name: 'user',
|
||||
initialState: null,
|
||||
reducers: {
|
||||
set: (state, action) => action.payload
|
||||
},
|
||||
});
|
||||
|
||||
export const offersState = createSlice({
|
||||
name: 'offers',
|
||||
initialState: [],
|
||||
reducers: {
|
||||
set: (state, action) => action.payload
|
||||
},
|
||||
});
|
||||
|
||||
export const wsState = createSlice({
|
||||
name: 'ws',
|
||||
initialState: null,
|
||||
reducers: {
|
||||
set: (state, action) => action.payload
|
||||
},
|
||||
});
|
||||
|
||||
const reducer = combineReducers({
|
||||
user: userState.reducer,
|
||||
offers: offersState.reducer,
|
||||
ws: wsState.reducer,
|
||||
});
|
||||
|
||||
const store = createStore(reducer);
|
||||
|
||||
export default store;
|
||||
|
||||
export type State = ReturnType<typeof store.getState>
|
||||
export type Dispatch = typeof store.dispatch
|
||||
Reference in new issue
Block a user