websocket-ts
websocket-ts copied to clipboard
WebsocketEvent enum problems
In consumer code it is not possible to use a string in the event listener:
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;
}
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