Skip to content

Commit b1670fd

Browse files
committed
Rename the example
1 parent 80c96c1 commit b1670fd

File tree

10 files changed

+29
-1
lines changed

10 files changed

+29
-1
lines changed

examples/react/start-typed-readable-stream/package.json renamed to examples/react/start-streaming-data-from-server-functions/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "tanstack-start-typed-readable-stream",
2+
"name": "tanstack-start-streaming-data-from-server-functions",
33
"private": true,
44
"sideEffects": false,
55
"type": "module",
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
This helper function generates the array of messages
3+
that we'll stream to the client.
4+
*/
5+
function generateMessages() {
6+
const messages = Array.from({ length: 10 }, () =>
7+
Math.floor(Math.random() * 100),
8+
).map((n, i) =>
9+
textPartSchema.parse({
10+
choices: [
11+
{
12+
delta: { content: `Number #${i + 1}: ${n}\n` },
13+
index: i,
14+
finish_reason: null,
15+
},
16+
],
17+
}),
18+
)
19+
return messages
20+
}
21+
22+
/**
23+
This helper function is used to simulate the
24+
delay between each message being sent.
25+
*/
26+
function sleep(ms: number) {
27+
return new Promise((resolve) => setTimeout(resolve, ms))
28+
}

0 commit comments

Comments
 (0)