UNPKG

@lumina-study/user-settings-redux

Version:

Redux store for Lumina Study user settings with unstorage persistence

34 lines 1.27 kB
import { Middleware } from '@reduxjs/toolkit'; import type { Storage } from 'unstorage'; import type { UserSettings } from '@lumina-study/user-settings'; /** * Storage key used for persisting user settings */ declare const STORAGE_KEY = "user-settings"; /** * Creates a Redux middleware that persists user settings to unstorage * * This middleware: * - Listens for changes to the userSettings slice * - Automatically saves the state to the provided unstorage driver * - Debounces writes to prevent excessive storage operations * * @param storage - The unstorage instance to use for persistence * @returns Redux middleware function */ export declare function createPersistenceMiddleware(storage: Storage): Middleware; /** * Loads user settings from storage * * @param storage - The unstorage instance to read from * @returns The persisted user settings, or null if not found or invalid */ export declare function loadPersistedSettings(storage: Storage): Promise<UserSettings | null>; /** * Clears persisted user settings from storage * * @param storage - The unstorage instance to clear from */ export declare function clearPersistedSettings(storage: Storage): Promise<void>; export { STORAGE_KEY }; //# sourceMappingURL=persistenceMiddleware.d.ts.map