import { getContext } from 'svelte'; import { BROWSER } from 'esm-env'; import { stores…
- User
import { getContext } from 'svelte'; import { BROWSER } from 'esm-env'; import { stores as browser_stores } from '../client/client.js';
/**
-
A function that returns all of the contextual stores. On the server, this must be called during component initialization.
-
Only use this if you need to defer store subscription until after the component has mounted, for some reason. */ export const getStores = () => { const stores = BROWSER ? browser_stores : getContext('svelte');
return { /** @type {typeof page} / page: { subscribe: stores.page.subscribe }, /* @type {typeof navigating} / navigating: { subscribe: stores.navigating.subscribe }, /* @type {typeof updated} */ updated: stores.updated }; };
/**
- A readable store whose value contains page data.
- On the server, this store can only be subscribed to during component initialization. In the browser, it can be subscribed to at any time.
- @type {import('svelte/store').Readable<import('@sveltejs/kit').Page>} */ export const page = { subscribe(fn) { const store = SVELTEKIT_DEV ? get_store('page') : getStores().page; return store.subscribe(fn); } };
/**
- A readable store.
- When navigating starts, its value is a
Navigationobject withfrom,to,typeand (iftype === 'popstate')deltaproperties. - When navigating finishes, its value reverts to
null. - On the server, this store can only be subscribed to during component initialization. In the browser, it can be subscribed to at any time.
- @type {import('svelte/store').Readable<import('@sveltejs/kit').Navigation | null>} */ export const navigating = { subscribe(fn) { const store = SVELTEKIT_DEV ? get_store('navigating') : getStores().navigating; return store.subscribe(fn); } };
/**
-
A readable store whose initial value is
false. Ifversion.pollIntervalis a non-zero value, SvelteKit will poll for new versions of the app and update the store value totruewhen it detects one.updated.check()will force an immediate check, regardless of polling. -
On the server, this store can only be subscribed to during component initialization. In the browser, it can be subscribed to at any time.
-
- Assistant