From b05132530f4ab08dd0ef2c13d1ac3cb75396c595 Mon Sep 17 00:00:00 2001 From: Bram Lemenu Date: Wed, 2 Oct 2024 14:18:05 +0200 Subject: [PATCH] Add optional id parameter to eventStream SendFunctionArgs --- src/server/event-stream.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/server/event-stream.ts b/src/server/event-stream.ts index 0597d67..a38771b 100644 --- a/src/server/event-stream.ts +++ b/src/server/event-stream.ts @@ -3,6 +3,7 @@ interface SendFunctionArgs { * @default "message" */ event?: string; + id?: string; data: string; } @@ -32,7 +33,8 @@ export function eventStream( start(controller) { let encoder = new TextEncoder(); - function send({ event = "message", data }: SendFunctionArgs) { + function send({ event = "message", id, data }: SendFunctionArgs) { + controller.enqueue(encoder.encode(`id: ${id}\n`)); controller.enqueue(encoder.encode(`event: ${event}\n`)); controller.enqueue(encoder.encode(`data: ${data}\n\n`)); }