development

This commit is contained in:
superdinmc
2025-11-10 17:37:51 +07:00 Unverified
parent 5b093a3dad
commit ef25566b65
7 changed files with 57 additions and 6 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
import { createContext, use, useEffect, useRef, useState } from "react";
type WebsiteComms = Partial<{ manual: boolean }>;
type WebsiteComms = Partial<{ manual: boolean, debug: boolean }>;
type WebsiteSignals = { beforeSubmit: undefined } & WebsiteComms;
+6 -2
View File
@@ -23,7 +23,10 @@ if (!globalThis.sseList) {
export class EventSourceManager {
private id = 0;
new(topic = "_global"): Response {
new(
topic = "_global",
{ onDisconnect }: { onDisconnect?: () => void } = {},
): Response {
let timeout: NodeJS.Timeout | undefined;
this.id++;
if (this.id > 100000) this.id = 0;
@@ -38,7 +41,8 @@ export class EventSourceManager {
globalThis.sseList.findIndex((e) => e.id === id),
1,
);
console.log(` SUB ${topic}#${id}`);
onDisconnect?.();
console.log(` DSC ${topic}#${id}`);
};
return new Response(
new ReadableStream({