forked from CodingCatDev/codingcat.dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstores.ts
More file actions
24 lines (20 loc) · 792 Bytes
/
stores.ts
File metadata and controls
24 lines (20 loc) · 792 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { writable, derived } from 'svelte/store';
import type { Writable } from 'svelte/store';
import { navigating } from "$app/stores";
// Set within root layout, persists current SvelteKit $page.url.pathname
export const storeCurrentUrl: Writable<string | undefined> = writable(undefined);
export const overlayMenuActive = writable(false);
export interface User {
email?: string;
picture?: string;
uid?: string;
}
export const storeUser: Writable<User | undefined> = writable(undefined);
let navTimer: number | NodeJS.Timeout | null | undefined = null;
export const navigationIsDelayed = derived(navigating, (newValue, set) => {
if (navTimer) { clearTimeout(navTimer); }
if (newValue) {
navTimer = setTimeout(() => set(true), 500);
}
set(false);
});