Files
fateverse-react/src/stores/cache.ts
2023-11-01 11:30:19 +08:00

27 lines
519 B
TypeScript

import { createSlice } from '@reduxjs/toolkit'
// type CacheKey = string
// type CacheVal = any
// const initCache = new Map<CacheKey, CacheVal>([])
// 创建一个slice
export const cacheSlice = createSlice({
name: 'cache',
// 初始化数据状态
initialState: {},
// 定义改变数据状态的方法
reducers: {
addCache(state, { payload }) {
state = {...state, ...payload}
return state
}
}
})
export const { addCache } = cacheSlice.actions
export default cacheSlice.reducer