import { navigate } from '$lib/Navigation'; import { getContext, setContext } from 'svelte'; import { writable, type Writable } from 'svelte/store'; export interface PaginationData { page: number; items: number; } export class PaginationContext { page = 0; items = 0; total = 0; set update({ page, items }: PaginationData) { this.page = page; this.items = items; } apply(params: URLSearchParams) { navigate({ pagination: { items: this.items } }, params); } } export function initPaginationContext() { return setContext>('pagination', writable(new PaginationContext())); } export function getPaginationContext() { return getContext>('pagination'); }