diff options
Diffstat (limited to 'src/js/builtins/EventStream.ts')
-rw-r--r-- | src/js/builtins/EventStream.ts | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/js/builtins/EventStream.ts b/src/js/builtins/EventStream.ts index c2ce30f17..c9d574836 100644 --- a/src/js/builtins/EventStream.ts +++ b/src/js/builtins/EventStream.ts @@ -16,12 +16,13 @@ export function getEventStream() { this.#ctrl = undefined; }, }); + $putByIdDirectPrivate(this, "contentType", "text/event-stream"); } send(event?: unknown, data?: unknown): void { var ctrl = this.#ctrl!; if (!ctrl) { - throw new Error("EventStream has ended"); + throw new Error("EventStream is closed"); } if (!data) { data = event; @@ -42,5 +43,9 @@ export function getEventStream() { } ctrl.flush(); } + + close() { + this.#ctrl?.close(); + } }; } |