From 72c9978cebe842eaa27a805b1c6a835e590ad179 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Thu, 15 Oct 2020 15:12:04 -0700 Subject: [PATCH] feat: Add 'connecting' event As described in the [comment here](https://github.com/yjs/y-websocket/issues/7#issuecomment-623114183), a "connecting" event is useful for monkey-patching the authentication process in lieu of a more official API. Seems like this is a no-brainer addition. --- src/y-websocket.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/y-websocket.js b/src/y-websocket.js index a1c0896..bb67bb6 100644 --- a/src/y-websocket.js +++ b/src/y-websocket.js @@ -84,6 +84,11 @@ const setupWS = provider => { provider.wsconnecting = true provider.wsconnected = false provider.synced = false + + provider.emit('status', [{ + status: 'connecting' + }]) + websocket.onmessage = event => { provider.wsLastMessageReceived = time.getUnixTime() const encoder = readMessage(provider, new Uint8Array(event.data), true)