[proposal] Can we provide WebSocket interfaces for customizing?
- Dominant language
- TypeScript
- Stars
- 40
- Forks
- 16
- PR merge metrics
- No merged PRs in 30d
Description
Hello, @kataras. the neffos.js works very well. but the coupling is too high. I want to change WebSocket. If there is an interface, I can implement it myself.
```js
interface EventCallback {
(evt: Event)
}
interface MsgCallback {
(evt: MessageEvent)
}
interface WebSocket {
Send(dat: string | ArrayBuffer);
Close();
OnMessage(cb: MsgCallback);
OnOpen(cb: EventCallback);
OnError(cb: EventCallback);
OnClose(cb: EventCallback);
}
// WS provided by the runtime
let ws = new WS;
let adapter: WebSocket = {
Send(dat) {
// logger
// ...
ws.send(dat)
},
Close(): void {
// ...
ws.close()
},
OnMessage(cb) {
// ...
ws.onMessage(cb);
},
OnOpen(cb) {
// ...
ws.onOpen(cb);
},
OnError(cb) {
// ...
ws.onErro(cb);
},
OnClose(cb) {
// ...
ws.onClose(cb);
}
};
neffos.SetWebsocketAdapter(adapter);
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by tracing the existing WebSocket coupling in the library and reviewing the proposed WebSocket and SetWebsocketAdapter entry points. Define the adapter boundary and verify browser and Node.js behavior; done means consumers can provide a replacement implementation without changing neffos.js behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs, typescript
- Domain
- api, networking
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100