Skip to content

Commit 1cb79db

Browse files
chore: interfaces for theme store (#584)
# Motivation Improve the types of the theme store by declaring interfaces as we commonly do nowadays. --------- Co-authored-by: Yusef Habib <[email protected]>
1 parent c0e822b commit 1cb79db

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/lib/stores/theme.store.ts

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
import type { Theme } from "$lib/types/theme";
22
import { applyTheme, initTheme } from "$lib/utils/theme.utils";
3-
import { writable } from "svelte/store";
3+
import { writable, type Readable } from "svelte/store";
44

5-
const initialTheme: Theme | undefined = initTheme();
5+
export type ThemeStoreData = Theme | undefined;
66

7-
export const initThemeStore = () => {
8-
const { subscribe, set } = writable<Theme | undefined>(initialTheme);
7+
export interface ThemeStore extends Readable<ThemeStoreData> {
8+
select: (theme: Theme) => void;
9+
}
10+
11+
const initialTheme: ThemeStoreData = initTheme();
12+
13+
export const initThemeStore = (): ThemeStore => {
14+
const { subscribe, set } = writable<ThemeStoreData>(initialTheme);
915

1016
return {
1117
subscribe,

0 commit comments

Comments
 (0)