We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents ec533e1 + 44677da commit 245ff25Copy full SHA for 245ff25
socket.ts
@@ -21,10 +21,20 @@ const version = "4.2.0";
21
22
export async function socketIO() {
23
const io = await importSocketIO();
24
- return io("https://scrapbox.io", {
+ const socket = io("https://scrapbox.io", {
25
reconnectionDelay: 5000,
26
transports: ["websocket"],
27
});
28
+
29
+ await new Promise<void>((resolve, reject) => {
30
+ const onDisconnect = (reason: Socket.DisconnectReason) => reject(reason);
31
+ socket.once("connect", () => {
32
+ socket.off("disconnect", onDisconnect);
33
+ resolve();
34
+ });
35
+ socket.once("disconnect", onDisconnect);
36
37
+ return socket;
38
}
39
40
function importSocketIO(): Promise<Window["io"]> {
0 commit comments