new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Svelte · SvelteKit · all subjects

load functions

3 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Streaming with promises in load functions

In SvelteKit 1.8 and later, you can return a nested promise from a server load function, and SvelteKit will start rendering the page before the promise resolves. Top-level properties are awaited before rendering begins. Nested promises (e.g., within a `streamed` object) are not awaited; instead, the page renders and the promise is sent to the browser where it resolves. Once the promise resolves, the result is streamed to the page.

Streaming example with server load function

Example of streaming non-essential data from a +page.server.js load function: ```ts export const load: PageServerLoad = () => { return { post: fetchPost(), streamed: { comments: fetchComments() } }; }; ``` SvelteKit automatically awaits `fetchPost()` before rendering. The `fetchComments()` promise is not awaited; it resolves asynchronously and the result is streamed to the client.

Streaming in templates with await block

In a +page.svelte component, access streamed data using Svelte's await block. The streamed promise becomes available as `data.streamed.propertyName` and can be awaited to show loading states and render content when the promise resolves.

Give your agent this brain