Skip to content

Conversation

hathamneh
Copy link

@hathamneh hathamneh commented Aug 23, 2024

This PR adds two features:

  • allow modification url after the websocket is built. ex: ws.url = 'some_new_url'
  • allow async events handlers: ex:
   WebsocketBuilder.onRetry(async (ws, ev) => {
     await someAsynTask();
   })

The use case needed those is:
We have a secured API that requires a temporary token per socket connection, so what is needed is to get a new token asynchronously then append it to the socket url:

   WebsocketBuilder.onRetry(async (ws, ev) => {
     const newToken = await someAsynTask();
     ws.url = `/myUrl?token=${newToken}`;
   })

@hathamneh hathamneh changed the title Allow async events add url mutation feature/Allow async events add url mutation Aug 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant