Skip to content

Commit

Permalink
add logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen Cefali committed Dec 23, 2023
1 parent f23e274 commit 4edc970
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/utils/event-stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,14 @@ export function eventStream(
init: InitFunction,
options: ResponseInit = {}
) {
console.log('Event Stream Called')
let stream = new ReadableStream({
start(controller) {
console.log('Event Stream Controller Started')
let encoder = new TextEncoder();

function send({ event = "message", data }: SendFunctionArgs) {
console.log('Event Stream Controller Send')
controller.enqueue(encoder.encode(`event: ${event}\n`));
controller.enqueue(encoder.encode(`data: ${data}\n\n`));
}
Expand All @@ -52,7 +55,7 @@ export function eventStream(
closed = true;
signal.removeEventListener("abort", close);
controller.close();
console.log('controller closed')
console.log('Event Stream Controller Closed')
}

signal.addEventListener("abort", close);
Expand Down

0 comments on commit 4edc970

Please sign in to comment.