ReactiveX / ReactiveX/rxjs

Using rxjs/webSocket on a server

Open
#5,385 16 comments 15 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
31.7k
Forks
3k
PR merge metrics
No merged PRs in 30d

Description

Feature Request

Right now WebSocketSubject only accepts a constructor. Can this be changed to also accept an existing socket in the config?

Specifically, my use case is that I'd like to use rxjs with websocket/ws on my server, and their API would allow me to do something like:

wss.on("connection", (ws: WebSocket) => {
  const rxjsWebSocket = webSocket(ws); // Wrap the node WebSocket into a subject.
});

wrt api compatibility, I think it's reasonable to assume the web socket remains w3c compatible instead of worrying about the NodeJS.WebSocket API. There are various compatibility shims to adapt the assorted NodeJS variants to w3c sockets. I'm curious if this was an intentional choice to not allow wrapping an existing socket or if this can be done?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/internal/observable/dom/WebSocketSubject.ts at the constructor and inspect the webSocket entry point. Determine how an existing W3C-compatible socket could be accepted for the websocket/ws server use case, then verify that wrapping such a socket works without changing the existing constructor behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
api, backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.