websocket-ts icon indicating copy to clipboard operation
websocket-ts copied to clipboard

WebsocketEvent enum problems

Open alexgleason opened this issue 11 months ago • 1 comments

In consumer code it is not possible to use a string in the event listener:

image

The only way is to import the the WebsocketEvent enum and use WebsocketEvent.open. IMO this should not be an enum at all, but an interface similar to the native WebSocketEventMap in TypeScript:

interface WebSocketEventMap {
  close: CloseEvent;
  error: Event;
  message: MessageEvent;
  open: Event;
}

alexgleason avatar Feb 25 '24 17:02 alexgleason

I made the greatest Nostr relay class ever using this library. Thank you for your service! https://gitlab.com/soapbox-pub/NSpec/-/blob/main/src/NRelay.ts

alexgleason avatar Feb 25 '24 19:02 alexgleason