Skeleton: Define dependencies when fetching data

This commit is contained in:
2025-02-17 21:15:00 +01:00
parent 25a55ec94e
commit 04b69611a1
8 changed files with 31 additions and 8 deletions

View File

@ -10,7 +10,9 @@ export const ssr = false;
// since it's populated inside hooks.server.ts per request.
// It will populate the "user" attribute of each page's "data" object,
// so each page has access to the current user (or knows if no one is signed in).
export const load: LayoutLoad = async () => {
export const load: LayoutLoad = async ({ fetch, depends }) => {
depends("data:graphics");
return {
// User information (synchronous)
user: pbUser,

View File

@ -1,7 +1,9 @@
import { fetch_drivers, fetch_raceresults, fetch_races } from "$lib/fetch";
import type { PageLoad } from "../../$types";
export const load: PageLoad = async ({ fetch }) => {
export const load: PageLoad = async ({ fetch, depends }) => {
depends("data:drivers", "data:races", "data:raceresults");
return {
drivers: fetch_drivers(fetch),
races: fetch_races(fetch),

View File

@ -1,7 +1,9 @@
import { fetch_drivers, fetch_teams } from "$lib/fetch";
import type { PageLoad } from "../../../$types";
export const load: PageLoad = async ({ fetch }) => {
export const load: PageLoad = async ({ fetch, depends }) => {
depends("data:teams", "data:drivers");
return {
teams: fetch_teams(fetch),
drivers: fetch_drivers(fetch),

View File

@ -1,7 +1,9 @@
import { fetch_races } from "$lib/fetch";
import type { PageLoad } from "../../../$types";
export const load: PageLoad = async ({ fetch }) => {
export const load: PageLoad = async ({ fetch, depends }) => {
depends("data:races");
return {
races: fetch_races(fetch),
};

View File

@ -1,7 +1,9 @@
import { fetch_drivers, fetch_races, fetch_substitutions } from "$lib/fetch";
import type { PageLoad } from "../../../$types";
export const load: PageLoad = async ({ fetch }) => {
export const load: PageLoad = async ({ fetch, depends }) => {
depends("data:races", "data:drivers", "data:substitutions");
return {
races: fetch_races(fetch),
drivers: fetch_drivers(fetch),

View File

@ -1,7 +1,9 @@
import { fetch_teams } from "$lib/fetch";
import type { PageLoad } from "../../../$types";
export const load: PageLoad = async ({ fetch }) => {
export const load: PageLoad = async ({ fetch, depends }) => {
depends("data:teams");
return {
teams: fetch_teams(fetch),
};

View File

@ -1,7 +1,9 @@
import { fetch_users } from "$lib/fetch";
import type { PageLoad } from "../../$types";
export const load: PageLoad = async ({ fetch }) => {
export const load: PageLoad = async ({ fetch, depends }) => {
depends("data:users");
return {
users: await fetch_users(fetch),
};

View File

@ -8,7 +8,16 @@ import {
} from "$lib/fetch";
import type { PageLoad } from "../$types";
export const load: PageLoad = async ({ fetch }) => {
export const load: PageLoad = async ({ fetch, depends }) => {
depends(
"data:racepicks",
"data:currentpickedusers",
"data:raceresults",
"data:drivers",
"data:races",
"data:currentrace",
);
return {
racepicks: fetch_racepicks(fetch),
currentpickedusers: fetch_currentpickedusers(fetch),