UNPKG

@lumina-study/user-settings-redux

Version:

Redux store for Lumina Study user settings with unstorage persistence

59 lines 2.15 kB
import type { Storage } from 'unstorage'; /** * Configuration options for creating the user settings store */ export interface CreateStoreOptions { /** * The unstorage driver instance to use for persistence */ storage: Storage; /** * Additional Redux DevTools options */ devTools?: boolean; } /** * Creates and initializes the Redux store for user settings * * This function: * 1. Creates a Redux store with the userSettings reducer * 2. Adds persistence middleware using the provided unstorage driver * 3. Loads any existing persisted settings from storage * 4. Initializes the store with the loaded settings (if any) * * @param options - Configuration options including the storage driver * @returns A promise that resolves to the configured Redux store * * @example * ```typescript * import { createStorage } from 'unstorage'; * import localStorageDriver from 'unstorage/drivers/localstorage'; * import { createUserSettingsStore } from '@lumina-study/user-settings-redux'; * * const storage = createStorage({ * driver: localStorageDriver({ base: 'app:' }) * }); * * const store = await createUserSettingsStore({ storage }); * ``` */ export declare function createUserSettingsStore(options: CreateStoreOptions): Promise<import("@reduxjs/toolkit").EnhancedStore<{ userSettings: import("@lumina-study/user-settings").UserSettings; }, import("@reduxjs/toolkit").UnknownAction, import("@reduxjs/toolkit").Tuple<[import("@reduxjs/toolkit").StoreEnhancer<{ dispatch: import("@reduxjs/toolkit").ThunkDispatch<{ userSettings: import("@lumina-study/user-settings").UserSettings; }, undefined, import("@reduxjs/toolkit").UnknownAction>; }>, import("@reduxjs/toolkit").StoreEnhancer]>>>; /** * Export type for the store */ export type UserSettingsStore = Awaited<ReturnType<typeof createUserSettingsStore>>; /** * Export RootState type for use with hooks */ export type RootState = ReturnType<UserSettingsStore['getState']>; /** * Export AppDispatch type for use with hooks */ export type AppDispatch = UserSettingsStore['dispatch']; //# sourceMappingURL=store.d.ts.map