Function: createBaseStore()
createBaseStore<
T>(set: (partial:Partial<T>) =>void):Pick<T,"clearError"|"isLoading"|"lastError"|"setError"|"setLoading">
Defined in: src/stores/utils.ts:42
Creates a base store slice with common error handling functionality.
Type Parametersโ
Tโ
T extends BaseStore
Parametersโ
setโ
(partial: Partial<T>) => void
Zustand set function for updating store state
Returnsโ
Pick<T, "clearError" | "isLoading" | "lastError" | "setError" | "setLoading">
Object containing common store methods and initial state values
Remarksโ
This function provides a standardized way to add error handling, loading states, and error management to any Zustand store. It ensures consistent error handling patterns across all stores in the application.
Exampleโ
const useMyStore = create<MyStore>((set, get) => ({
    ...createBaseStore(set),
    // ... other store properties
}));