我想在我的useGlobalStore
. 我想在那里处理(设置和获取)会话存储的数据。我浏览了文档,但找不到如何将我的create
和persist
功能组合在一起的答案。
这是我的useGlobalStore
:
interface Store extends HeatMapState, WeeklyOverviewState, MonthlyOverviewState, GlobalState, UserState {}
export const useGlobalStore = create<Store>(
devtools((set, get, api) => ({
...heatMapSlice(set as SetState<HeatMapState>, get as GetState<HeatMapState>, api as StoreApi<HeatMapState>),
...weeklyOverviewSlice(
set as SetState<WeeklyOverviewState>,
get as GetState<WeeklyOverviewState>,
api as StoreApi<WeeklyOverviewState>,
),
...monthlyOverviewSlice(
set as SetState<MonthlyOverviewState>,
get as GetState<MonthlyOverviewState>,
api as StoreApi<MonthlyOverviewState>,
),
...globalStateSlice(set as SetState<GlobalState>, get as GetState<GlobalState>, api as StoreApi<GlobalState>),
...userStateSlice(set as SetState<UserState>, get as GetState<UserState>, api as StoreApi<UserState>),
})),
) as UseBoundStore<Store, StoreApi<Store>>