Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/Allow async events add url mutation #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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