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

feat(useWebSocket): allow undefined ref for url #2473

Merged
merged 2 commits into from Jan 29, 2023
Merged

feat(useWebSocket): allow undefined ref for url #2473

merged 2 commits into from Jan 29, 2023

Conversation

ferferga
Copy link
Contributor

@ferferga ferferga commented Nov 23, 2022

Description

I want to have a a global WebSocket in my app. Since the introduction of ref passing to useWebSocket, useWebSocket is much more useful for scenarios where you change between servers, since I can always expect the WebSocket to work and be up to date without any manual handling from our side. Everything works thanks to vue computed (to construct the webSocket url) and a ref to an object which contains the server URL.

However, expecting only URLs or strings makes it really difficult to have that webSocket always globally: there are situations in my app where no server is defined. Without this PR, I need to have a watcher and then instantiate the socket using useWebSocket. This PR solves all this logic.

Additional context

I also fixed the docs, which were with outdated types


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
    • feat(useWebSocket): redefine url / parameter #2200 is very similar in what this PR wants to aim. However, it's outdated, as it doesn't take into account that url can now be a ref, so my proposed solution for this make it much simpler for this kind of scenarios.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

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.

None yet

2 participants