You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 14c454c
Browse filesBrowse the repository at this point in the historyBrowse files
live(fn) declares GET itself (solid rc.17) and router liveQuery declares
a server function live() itself (router next.42): drop live(GET(...))
and liveQuery(live(...)) from the guides and the router reference.
Claude-Session: https://claude.ai/code/session_01Fmb4aQtDJWoA8CUktR9QoZ
Co-authored-by: Claude <noreply@anthropic.com>
`GET()` chooses the read transport, and `live()` wraps the call behavior around it, so it must be the outermost declaration.
143
-
`live()` does not imply `GET()`; a live source without it streams over `POST`, which is fine when a cacheable URL is of no use.
139
+
A live source is a read, so `live()` declares it `GET` itself; the connection uses the read transport without a separate `GET()`.
144
140
145
141
The source yields the current count first, every time it is invoked.
146
142
That is the contract a reconnect depends on: when the connection drops and the client calls again, the first yield replaces the stale answer, and no client-side cache is needed to fill the gap.
@@ -267,7 +263,7 @@ Check the server log for the status: the client retries only transient failures
267
263
- A `GET()` read puts its arguments in the URL; keep secrets out of them and read identity from the request event.
268
264
- Responses leave with `Cache-Control: no-store`; return `respond(value, { headers })` to opt a read into caching.
269
265
- Return an async iterable to stream events over one connection; ending the iteration in the browser ends the server producer.
270
-
- Declare a value that changes over time with `live(GET(fn))`, `live()` outermost, and yield the current value first on every invocation.
266
+
- Declare a value that changes over time with `live(fn)`, which declares it `GET` as well, and yield the current value first on every invocation.
271
267
- Read a live source through one memo and pass the value down; each call site that invokes the source opens its own connection.
272
268
- Use `onstatus` to show a reconnect; put data freshness in the yielded value.
Copy file name to clipboardExpand all lines: src/routes/(3)building-apps/(3)server-functions/(4)metadata-and-transport.mdx
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -57,15 +57,15 @@ The `Avoid` version places any order for any caller; `requiresAuth` is a value o
57
57
58
58
Later `withMeta()` calls shallow-merge over earlier metadata.
59
59
`GET()` uses the same channel for its HTTP method, and the two compose in either order.
60
-
`live()` wraps the call behavior, so it goes outside both:
60
+
`live()` wraps the call behavior and declares `GET` itself, so it goes outside `withMeta()` and needs no `GET()`:
61
61
62
62
```ts
63
63
exportconst stockLevels =live(
64
64
withMeta(
65
-
GET(asyncfunction* () {
65
+
asyncfunction* () {
66
66
"use server";
67
67
yield*inventory.levels();
68
-
}),
68
+
},
69
69
{ channel: "inventory" }
70
70
)
71
71
);
@@ -224,7 +224,7 @@ Check the condition in the hook against the metadata on the reference, and move
224
224
225
225
- The defaults are a `POST` to `/_server/data/<id>` with the argument array as the body and `Cache-Control: no-store` on the response; change them only for a reason on this page.
226
226
- Attach static facts to a declaration with `withMeta()`; the server does not read them, so enforce policy in the body.
227
-
- Compose `withMeta()` and `GET()` in either order, and put `live()`outside both.
227
+
- Compose `withMeta()` and `GET()` in either order, and put `live()`, which implies `GET()`, outside `withMeta()`.
228
228
- Add session-dependent headers in one `prepareRequest` hook, configured once in the client entry before the first call.
229
229
- Move the endpoint with the plugin's `serverFunctions.endpoint` option so client and server stay matched.
230
230
- Pass `signal`, `keepalive`, or `priority` to one call through `invoke()`; anything longer-lived is refused with a pointer to its home.
The request's signal ends the watcher when the reader leaves; the job does not see it.
@@ -221,7 +219,7 @@ A projection rather than a memo keeps readers of `reply.status` out of every tex
221
219
`refresh(reply)` re-runs the projection, which opens a new connection; it does not touch the job.
222
220
223
221
Every call site that iterates a live source holds its own connection.
224
-
When the thread list and the thread both need the same reply, hoist the read, or declare it with Solid Router's [`liveQuery`](/reference/solid-router/data#livequery), which keeps one connection per key for every consumer; the spelling is `liveQuery(watchReply, "reply")`, and a function already declared with `live(GET())` passes through unchanged.
222
+
When the thread list and the thread both need the same reply, hoist the read, or declare it with Solid Router's [`liveQuery`](/reference/solid-router/data#livequery), which keeps one connection per key for every consumer; the spelling is `liveQuery(watchReply, "reply")`. `liveQuery` declares a server function `live()` itself, and one already declared `live()` passes through unchanged.
225
223
226
224
## Hold the bubble until the stream confirms
227
225
@@ -288,55 +286,49 @@ The `chat` example in the Solid repository is this section's reference implement
288
286
:::
289
287
290
288
When the markdown renderer, the highlighter, and the model client should stay on the server, the thread can be server markup that keeps changing.
291
-
The server function returns a component instead of data, and `live()` holds the response open while it re-renders:
289
+
The server function returns a component instead of data, and `liveQuery`, which declares it `live()`, holds the response open while it re-renders:
292
290
293
291
```tsx
294
292
// src/routes/thread.tsx
295
293
import { createMemo, onCleanup } from"solid-js";
296
294
import { getRequestEvent } from"@solidjs/web";
297
-
import { GET, live } from"@solidjs/web/server-functions";
`threads.watch` is the thread-level watcher: it yields the thread and its messages after every write to any of them.
@@ -420,8 +412,8 @@ Await it from an action body or another imperative scope.
420
412
421
413
- Start the generation from a server function that returns at once; the job belongs to a module-level registry and writes the reply into a store as it arrives.
422
414
- Pass the job its own abort signal; the request's signal ends only the watcher.
423
-
- Deliver the reply through `live(GET(async function*))`, yielding the whole reply so far and the current reply first on every connection.
424
-
- Render it in the browser with `createProjection`, or on the server as a live server component mounted with `dynamicComponent` through `liveQuery(live(GET(fn)), key)`.
415
+
- Deliver the reply through `live(async function*)`, yielding the whole reply so far and the current reply first on every connection.
416
+
- Render it in the browser with `createProjection`, or on the server as a live server component mounted with `dynamicComponent` through `liveQuery(fn, key)`.
425
417
- Hold an optimistic row with `createOptimisticStore` inside an `action`, confirm it with `until` over the live thread's ids, and filter the row by the same ids.
426
418
- A reconnect sends `Last-Event-ID`; an unchanged first value is skipped, and partial replay needs a log the source reads the header against.
- Consumers of one key share one connection. A late consumer receives the latest value first. The connection closes when the last consumer leaves.
103
103
- A stream that has delivered a value and then fails with a network error or a 5xx status reconnects with exponential backoff. The latest value stays available meanwhile.
104
104
- A failure before the first value, or a 4xx status, ends the channel and throws to consumers.
105
-
- When `fn` is a server function without a declared method, `liveQuery` wraps it as a GET server function.
105
+
- When `fn` is a server function, `liveQuery` declares it with `live()`, which implies `GET`, so the connection gets the transport's live lifecycle. A function already declared with `live()` passes through unchanged.
106
106
- A call under preload intent connects the channel and holds it open for 5 seconds.
107
107
- Mutations do not revalidate live keys. `revalidate(key)` with `force` reconnects the matching channels.
108
108
- On the server, the document renders the first value. Hydration adopts it and reconnects.
0 commit comments